x11rb/protocol/
render.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `Render` 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::xproto;
27
28pub use x11rb_protocol::protocol::render::*;
29
30/// Get the major opcode of this extension
31fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> {
32    let info = conn.extension_information(X11_EXTENSION_NAME)?;
33    let info = info.ok_or(ConnectionError::UnsupportedExtension)?;
34    Ok(info.major_opcode)
35}
36
37pub fn query_version<Conn>(conn: &Conn, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
38where
39    Conn: RequestConnection + ?Sized,
40{
41    let request0 = QueryVersionRequest {
42        client_major_version,
43        client_minor_version,
44    };
45    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
46    let slices = [IoSlice::new(&bytes[0])];
47    assert_eq!(slices.len(), bytes.len());
48    conn.send_request_with_reply(&slices, fds)
49}
50
51pub fn query_pict_formats<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryPictFormatsReply>, ConnectionError>
52where
53    Conn: RequestConnection + ?Sized,
54{
55    let request0 = QueryPictFormatsRequest;
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
62pub fn query_pict_index_values<Conn>(conn: &Conn, format: Pictformat) -> Result<Cookie<'_, Conn, QueryPictIndexValuesReply>, ConnectionError>
63where
64    Conn: RequestConnection + ?Sized,
65{
66    let request0 = QueryPictIndexValuesRequest {
67        format,
68    };
69    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
70    let slices = [IoSlice::new(&bytes[0])];
71    assert_eq!(slices.len(), bytes.len());
72    conn.send_request_with_reply(&slices, fds)
73}
74
75pub fn create_picture<'c, 'input, Conn>(conn: &'c Conn, pid: Picture, drawable: xproto::Drawable, format: Pictformat, value_list: &'input CreatePictureAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
76where
77    Conn: RequestConnection + ?Sized,
78{
79    let request0 = CreatePictureRequest {
80        pid,
81        drawable,
82        format,
83        value_list: Cow::Borrowed(value_list),
84    };
85    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
86    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
87    assert_eq!(slices.len(), bytes.len());
88    conn.send_request_without_reply(&slices, fds)
89}
90
91pub fn change_picture<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, value_list: &'input ChangePictureAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
92where
93    Conn: RequestConnection + ?Sized,
94{
95    let request0 = ChangePictureRequest {
96        picture,
97        value_list: Cow::Borrowed(value_list),
98    };
99    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
100    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
101    assert_eq!(slices.len(), bytes.len());
102    conn.send_request_without_reply(&slices, fds)
103}
104
105pub fn set_picture_clip_rectangles<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, clip_x_origin: i16, clip_y_origin: i16, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
106where
107    Conn: RequestConnection + ?Sized,
108{
109    let request0 = SetPictureClipRectanglesRequest {
110        picture,
111        clip_x_origin,
112        clip_y_origin,
113        rectangles: Cow::Borrowed(rectangles),
114    };
115    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
116    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
117    assert_eq!(slices.len(), bytes.len());
118    conn.send_request_without_reply(&slices, fds)
119}
120
121pub fn free_picture<Conn>(conn: &Conn, picture: Picture) -> Result<VoidCookie<'_, Conn>, ConnectionError>
122where
123    Conn: RequestConnection + ?Sized,
124{
125    let request0 = FreePictureRequest {
126        picture,
127    };
128    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
129    let slices = [IoSlice::new(&bytes[0])];
130    assert_eq!(slices.len(), bytes.len());
131    conn.send_request_without_reply(&slices, fds)
132}
133
134pub fn composite<Conn, A>(conn: &Conn, op: PictOp, src: Picture, mask: A, dst: Picture, src_x: i16, src_y: i16, mask_x: i16, mask_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
135where
136    Conn: RequestConnection + ?Sized,
137    A: Into<Picture>,
138{
139    let mask: Picture = mask.into();
140    let request0 = CompositeRequest {
141        op,
142        src,
143        mask,
144        dst,
145        src_x,
146        src_y,
147        mask_x,
148        mask_y,
149        dst_x,
150        dst_y,
151        width,
152        height,
153    };
154    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
155    let slices = [IoSlice::new(&bytes[0])];
156    assert_eq!(slices.len(), bytes.len());
157    conn.send_request_without_reply(&slices, fds)
158}
159
160pub fn trapezoids<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, traps: &'input [Trapezoid]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
161where
162    Conn: RequestConnection + ?Sized,
163{
164    let request0 = TrapezoidsRequest {
165        op,
166        src,
167        dst,
168        mask_format,
169        src_x,
170        src_y,
171        traps: Cow::Borrowed(traps),
172    };
173    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
174    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
175    assert_eq!(slices.len(), bytes.len());
176    conn.send_request_without_reply(&slices, fds)
177}
178
179pub fn triangles<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, triangles: &'input [Triangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
180where
181    Conn: RequestConnection + ?Sized,
182{
183    let request0 = TrianglesRequest {
184        op,
185        src,
186        dst,
187        mask_format,
188        src_x,
189        src_y,
190        triangles: Cow::Borrowed(triangles),
191    };
192    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
193    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
194    assert_eq!(slices.len(), bytes.len());
195    conn.send_request_without_reply(&slices, fds)
196}
197
198pub fn tri_strip<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
199where
200    Conn: RequestConnection + ?Sized,
201{
202    let request0 = TriStripRequest {
203        op,
204        src,
205        dst,
206        mask_format,
207        src_x,
208        src_y,
209        points: Cow::Borrowed(points),
210    };
211    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
212    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
213    assert_eq!(slices.len(), bytes.len());
214    conn.send_request_without_reply(&slices, fds)
215}
216
217pub fn tri_fan<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
218where
219    Conn: RequestConnection + ?Sized,
220{
221    let request0 = TriFanRequest {
222        op,
223        src,
224        dst,
225        mask_format,
226        src_x,
227        src_y,
228        points: Cow::Borrowed(points),
229    };
230    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
231    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
232    assert_eq!(slices.len(), bytes.len());
233    conn.send_request_without_reply(&slices, fds)
234}
235
236pub fn create_glyph_set<Conn>(conn: &Conn, gsid: Glyphset, format: Pictformat) -> Result<VoidCookie<'_, Conn>, ConnectionError>
237where
238    Conn: RequestConnection + ?Sized,
239{
240    let request0 = CreateGlyphSetRequest {
241        gsid,
242        format,
243    };
244    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
245    let slices = [IoSlice::new(&bytes[0])];
246    assert_eq!(slices.len(), bytes.len());
247    conn.send_request_without_reply(&slices, fds)
248}
249
250pub fn reference_glyph_set<Conn>(conn: &Conn, gsid: Glyphset, existing: Glyphset) -> Result<VoidCookie<'_, Conn>, ConnectionError>
251where
252    Conn: RequestConnection + ?Sized,
253{
254    let request0 = ReferenceGlyphSetRequest {
255        gsid,
256        existing,
257    };
258    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
259    let slices = [IoSlice::new(&bytes[0])];
260    assert_eq!(slices.len(), bytes.len());
261    conn.send_request_without_reply(&slices, fds)
262}
263
264pub fn free_glyph_set<Conn>(conn: &Conn, glyphset: Glyphset) -> Result<VoidCookie<'_, Conn>, ConnectionError>
265where
266    Conn: RequestConnection + ?Sized,
267{
268    let request0 = FreeGlyphSetRequest {
269        glyphset,
270    };
271    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
272    let slices = [IoSlice::new(&bytes[0])];
273    assert_eq!(slices.len(), bytes.len());
274    conn.send_request_without_reply(&slices, fds)
275}
276
277pub fn add_glyphs<'c, 'input, Conn>(conn: &'c Conn, glyphset: Glyphset, glyphids: &'input [u32], glyphs: &'input [Glyphinfo], data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
278where
279    Conn: RequestConnection + ?Sized,
280{
281    let request0 = AddGlyphsRequest {
282        glyphset,
283        glyphids: Cow::Borrowed(glyphids),
284        glyphs: Cow::Borrowed(glyphs),
285        data: Cow::Borrowed(data),
286    };
287    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
288    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2]), IoSlice::new(&bytes[3]), IoSlice::new(&bytes[4])];
289    assert_eq!(slices.len(), bytes.len());
290    conn.send_request_without_reply(&slices, fds)
291}
292
293pub fn free_glyphs<'c, 'input, Conn>(conn: &'c Conn, glyphset: Glyphset, glyphs: &'input [Glyph]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
294where
295    Conn: RequestConnection + ?Sized,
296{
297    let request0 = FreeGlyphsRequest {
298        glyphset,
299        glyphs: Cow::Borrowed(glyphs),
300    };
301    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
302    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
303    assert_eq!(slices.len(), bytes.len());
304    conn.send_request_without_reply(&slices, fds)
305}
306
307pub fn composite_glyphs8<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
308where
309    Conn: RequestConnection + ?Sized,
310{
311    let request0 = CompositeGlyphs8Request {
312        op,
313        src,
314        dst,
315        mask_format,
316        glyphset,
317        src_x,
318        src_y,
319        glyphcmds: Cow::Borrowed(glyphcmds),
320    };
321    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
322    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
323    assert_eq!(slices.len(), bytes.len());
324    conn.send_request_without_reply(&slices, fds)
325}
326
327pub fn composite_glyphs16<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
328where
329    Conn: RequestConnection + ?Sized,
330{
331    let request0 = CompositeGlyphs16Request {
332        op,
333        src,
334        dst,
335        mask_format,
336        glyphset,
337        src_x,
338        src_y,
339        glyphcmds: Cow::Borrowed(glyphcmds),
340    };
341    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
342    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
343    assert_eq!(slices.len(), bytes.len());
344    conn.send_request_without_reply(&slices, fds)
345}
346
347pub fn composite_glyphs32<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
348where
349    Conn: RequestConnection + ?Sized,
350{
351    let request0 = CompositeGlyphs32Request {
352        op,
353        src,
354        dst,
355        mask_format,
356        glyphset,
357        src_x,
358        src_y,
359        glyphcmds: Cow::Borrowed(glyphcmds),
360    };
361    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
362    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
363    assert_eq!(slices.len(), bytes.len());
364    conn.send_request_without_reply(&slices, fds)
365}
366
367pub fn fill_rectangles<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, dst: Picture, color: Color, rects: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
368where
369    Conn: RequestConnection + ?Sized,
370{
371    let request0 = FillRectanglesRequest {
372        op,
373        dst,
374        color,
375        rects: Cow::Borrowed(rects),
376    };
377    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
378    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
379    assert_eq!(slices.len(), bytes.len());
380    conn.send_request_without_reply(&slices, fds)
381}
382
383pub fn create_cursor<Conn>(conn: &Conn, cid: xproto::Cursor, source: Picture, x: u16, y: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
384where
385    Conn: RequestConnection + ?Sized,
386{
387    let request0 = CreateCursorRequest {
388        cid,
389        source,
390        x,
391        y,
392    };
393    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
394    let slices = [IoSlice::new(&bytes[0])];
395    assert_eq!(slices.len(), bytes.len());
396    conn.send_request_without_reply(&slices, fds)
397}
398
399pub fn set_picture_transform<Conn>(conn: &Conn, picture: Picture, transform: Transform) -> Result<VoidCookie<'_, Conn>, ConnectionError>
400where
401    Conn: RequestConnection + ?Sized,
402{
403    let request0 = SetPictureTransformRequest {
404        picture,
405        transform,
406    };
407    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
408    let slices = [IoSlice::new(&bytes[0])];
409    assert_eq!(slices.len(), bytes.len());
410    conn.send_request_without_reply(&slices, fds)
411}
412
413pub fn query_filters<Conn>(conn: &Conn, drawable: xproto::Drawable) -> Result<Cookie<'_, Conn, QueryFiltersReply>, ConnectionError>
414where
415    Conn: RequestConnection + ?Sized,
416{
417    let request0 = QueryFiltersRequest {
418        drawable,
419    };
420    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
421    let slices = [IoSlice::new(&bytes[0])];
422    assert_eq!(slices.len(), bytes.len());
423    conn.send_request_with_reply(&slices, fds)
424}
425
426pub fn set_picture_filter<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, filter: &'input [u8], values: &'input [Fixed]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
427where
428    Conn: RequestConnection + ?Sized,
429{
430    let request0 = SetPictureFilterRequest {
431        picture,
432        filter: Cow::Borrowed(filter),
433        values: Cow::Borrowed(values),
434    };
435    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
436    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2]), IoSlice::new(&bytes[3]), IoSlice::new(&bytes[4])];
437    assert_eq!(slices.len(), bytes.len());
438    conn.send_request_without_reply(&slices, fds)
439}
440
441pub fn create_anim_cursor<'c, 'input, Conn>(conn: &'c Conn, cid: xproto::Cursor, cursors: &'input [Animcursorelt]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
442where
443    Conn: RequestConnection + ?Sized,
444{
445    let request0 = CreateAnimCursorRequest {
446        cid,
447        cursors: Cow::Borrowed(cursors),
448    };
449    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
450    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
451    assert_eq!(slices.len(), bytes.len());
452    conn.send_request_without_reply(&slices, fds)
453}
454
455pub fn add_traps<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, x_off: i16, y_off: i16, traps: &'input [Trap]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
456where
457    Conn: RequestConnection + ?Sized,
458{
459    let request0 = AddTrapsRequest {
460        picture,
461        x_off,
462        y_off,
463        traps: Cow::Borrowed(traps),
464    };
465    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
466    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
467    assert_eq!(slices.len(), bytes.len());
468    conn.send_request_without_reply(&slices, fds)
469}
470
471pub fn create_solid_fill<Conn>(conn: &Conn, picture: Picture, color: Color) -> Result<VoidCookie<'_, Conn>, ConnectionError>
472where
473    Conn: RequestConnection + ?Sized,
474{
475    let request0 = CreateSolidFillRequest {
476        picture,
477        color,
478    };
479    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
480    let slices = [IoSlice::new(&bytes[0])];
481    assert_eq!(slices.len(), bytes.len());
482    conn.send_request_without_reply(&slices, fds)
483}
484
485pub fn create_linear_gradient<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, p1: Pointfix, p2: Pointfix, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
486where
487    Conn: RequestConnection + ?Sized,
488{
489    let request0 = CreateLinearGradientRequest {
490        picture,
491        p1,
492        p2,
493        stops: Cow::Borrowed(stops),
494        colors: Cow::Borrowed(colors),
495    };
496    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
497    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2]), IoSlice::new(&bytes[3])];
498    assert_eq!(slices.len(), bytes.len());
499    conn.send_request_without_reply(&slices, fds)
500}
501
502pub fn create_radial_gradient<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, inner: Pointfix, outer: Pointfix, inner_radius: Fixed, outer_radius: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
503where
504    Conn: RequestConnection + ?Sized,
505{
506    let request0 = CreateRadialGradientRequest {
507        picture,
508        inner,
509        outer,
510        inner_radius,
511        outer_radius,
512        stops: Cow::Borrowed(stops),
513        colors: Cow::Borrowed(colors),
514    };
515    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
516    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2]), IoSlice::new(&bytes[3])];
517    assert_eq!(slices.len(), bytes.len());
518    conn.send_request_without_reply(&slices, fds)
519}
520
521pub fn create_conical_gradient<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, center: Pointfix, angle: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
522where
523    Conn: RequestConnection + ?Sized,
524{
525    let request0 = CreateConicalGradientRequest {
526        picture,
527        center,
528        angle,
529        stops: Cow::Borrowed(stops),
530        colors: Cow::Borrowed(colors),
531    };
532    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
533    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2]), IoSlice::new(&bytes[3])];
534    assert_eq!(slices.len(), bytes.len());
535    conn.send_request_without_reply(&slices, fds)
536}
537
538/// Extension trait defining the requests of this extension.
539pub trait ConnectionExt: RequestConnection {
540    fn render_query_version(&self, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>
541    {
542        query_version(self, client_major_version, client_minor_version)
543    }
544    fn render_query_pict_formats(&self) -> Result<Cookie<'_, Self, QueryPictFormatsReply>, ConnectionError>
545    {
546        query_pict_formats(self)
547    }
548    fn render_query_pict_index_values(&self, format: Pictformat) -> Result<Cookie<'_, Self, QueryPictIndexValuesReply>, ConnectionError>
549    {
550        query_pict_index_values(self, format)
551    }
552    fn render_create_picture<'c, 'input>(&'c self, pid: Picture, drawable: xproto::Drawable, format: Pictformat, value_list: &'input CreatePictureAux) -> Result<VoidCookie<'c, Self>, ConnectionError>
553    {
554        create_picture(self, pid, drawable, format, value_list)
555    }
556    fn render_change_picture<'c, 'input>(&'c self, picture: Picture, value_list: &'input ChangePictureAux) -> Result<VoidCookie<'c, Self>, ConnectionError>
557    {
558        change_picture(self, picture, value_list)
559    }
560    fn render_set_picture_clip_rectangles<'c, 'input>(&'c self, picture: Picture, clip_x_origin: i16, clip_y_origin: i16, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>
561    {
562        set_picture_clip_rectangles(self, picture, clip_x_origin, clip_y_origin, rectangles)
563    }
564    fn render_free_picture(&self, picture: Picture) -> Result<VoidCookie<'_, Self>, ConnectionError>
565    {
566        free_picture(self, picture)
567    }
568    fn render_composite<A>(&self, op: PictOp, src: Picture, mask: A, dst: Picture, src_x: i16, src_y: i16, mask_x: i16, mask_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
569    where
570        A: Into<Picture>,
571    {
572        composite(self, op, src, mask, dst, src_x, src_y, mask_x, mask_y, dst_x, dst_y, width, height)
573    }
574    fn render_trapezoids<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, traps: &'input [Trapezoid]) -> Result<VoidCookie<'c, Self>, ConnectionError>
575    {
576        trapezoids(self, op, src, dst, mask_format, src_x, src_y, traps)
577    }
578    fn render_triangles<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, triangles: &'input [Triangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>
579    {
580        self::triangles(self, op, src, dst, mask_format, src_x, src_y, triangles)
581    }
582    fn render_tri_strip<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Self>, ConnectionError>
583    {
584        tri_strip(self, op, src, dst, mask_format, src_x, src_y, points)
585    }
586    fn render_tri_fan<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Self>, ConnectionError>
587    {
588        tri_fan(self, op, src, dst, mask_format, src_x, src_y, points)
589    }
590    fn render_create_glyph_set(&self, gsid: Glyphset, format: Pictformat) -> Result<VoidCookie<'_, Self>, ConnectionError>
591    {
592        create_glyph_set(self, gsid, format)
593    }
594    fn render_reference_glyph_set(&self, gsid: Glyphset, existing: Glyphset) -> Result<VoidCookie<'_, Self>, ConnectionError>
595    {
596        reference_glyph_set(self, gsid, existing)
597    }
598    fn render_free_glyph_set(&self, glyphset: Glyphset) -> Result<VoidCookie<'_, Self>, ConnectionError>
599    {
600        free_glyph_set(self, glyphset)
601    }
602    fn render_add_glyphs<'c, 'input>(&'c self, glyphset: Glyphset, glyphids: &'input [u32], glyphs: &'input [Glyphinfo], data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
603    {
604        add_glyphs(self, glyphset, glyphids, glyphs, data)
605    }
606    fn render_free_glyphs<'c, 'input>(&'c self, glyphset: Glyphset, glyphs: &'input [Glyph]) -> Result<VoidCookie<'c, Self>, ConnectionError>
607    {
608        free_glyphs(self, glyphset, glyphs)
609    }
610    fn render_composite_glyphs8<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
611    {
612        composite_glyphs8(self, op, src, dst, mask_format, glyphset, src_x, src_y, glyphcmds)
613    }
614    fn render_composite_glyphs16<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
615    {
616        composite_glyphs16(self, op, src, dst, mask_format, glyphset, src_x, src_y, glyphcmds)
617    }
618    fn render_composite_glyphs32<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
619    {
620        composite_glyphs32(self, op, src, dst, mask_format, glyphset, src_x, src_y, glyphcmds)
621    }
622    fn render_fill_rectangles<'c, 'input>(&'c self, op: PictOp, dst: Picture, color: Color, rects: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>
623    {
624        fill_rectangles(self, op, dst, color, rects)
625    }
626    fn render_create_cursor(&self, cid: xproto::Cursor, source: Picture, x: u16, y: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
627    {
628        create_cursor(self, cid, source, x, y)
629    }
630    fn render_set_picture_transform(&self, picture: Picture, transform: Transform) -> Result<VoidCookie<'_, Self>, ConnectionError>
631    {
632        set_picture_transform(self, picture, transform)
633    }
634    fn render_query_filters(&self, drawable: xproto::Drawable) -> Result<Cookie<'_, Self, QueryFiltersReply>, ConnectionError>
635    {
636        query_filters(self, drawable)
637    }
638    fn render_set_picture_filter<'c, 'input>(&'c self, picture: Picture, filter: &'input [u8], values: &'input [Fixed]) -> Result<VoidCookie<'c, Self>, ConnectionError>
639    {
640        set_picture_filter(self, picture, filter, values)
641    }
642    fn render_create_anim_cursor<'c, 'input>(&'c self, cid: xproto::Cursor, cursors: &'input [Animcursorelt]) -> Result<VoidCookie<'c, Self>, ConnectionError>
643    {
644        create_anim_cursor(self, cid, cursors)
645    }
646    fn render_add_traps<'c, 'input>(&'c self, picture: Picture, x_off: i16, y_off: i16, traps: &'input [Trap]) -> Result<VoidCookie<'c, Self>, ConnectionError>
647    {
648        add_traps(self, picture, x_off, y_off, traps)
649    }
650    fn render_create_solid_fill(&self, picture: Picture, color: Color) -> Result<VoidCookie<'_, Self>, ConnectionError>
651    {
652        create_solid_fill(self, picture, color)
653    }
654    fn render_create_linear_gradient<'c, 'input>(&'c self, picture: Picture, p1: Pointfix, p2: Pointfix, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Self>, ConnectionError>
655    {
656        create_linear_gradient(self, picture, p1, p2, stops, colors)
657    }
658    fn render_create_radial_gradient<'c, 'input>(&'c self, picture: Picture, inner: Pointfix, outer: Pointfix, inner_radius: Fixed, outer_radius: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Self>, ConnectionError>
659    {
660        create_radial_gradient(self, picture, inner, outer, inner_radius, outer_radius, stops, colors)
661    }
662    fn render_create_conical_gradient<'c, 'input>(&'c self, picture: Picture, center: Pointfix, angle: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Self>, ConnectionError>
663    {
664        create_conical_gradient(self, picture, center, angle, stops, colors)
665    }
666}
667
668impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
669
670/// A RAII-like wrapper around a [Picture].
671///
672/// Instances of this struct represent a Picture that is freed in `Drop`.
673///
674/// Any errors during `Drop` are silently ignored. Most likely an error here means that your
675/// X11 connection is broken and later requests will also fail.
676#[derive(Debug)]
677pub struct PictureWrapper<C: RequestConnection>(C, Picture);
678
679impl<C: RequestConnection> PictureWrapper<C>
680{
681    /// Assume ownership of the given resource and destroy it in `Drop`.
682    pub fn for_picture(conn: C, id: Picture) -> Self {
683        PictureWrapper(conn, id)
684    }
685
686    /// Get the XID of the wrapped resource
687    pub fn picture(&self) -> Picture {
688        self.1
689    }
690
691    /// Assume ownership of the XID of the wrapped resource
692    ///
693    /// This function destroys this wrapper without freeing the underlying resource.
694    pub fn into_picture(self) -> Picture {
695        let id = self.1;
696        std::mem::forget(self);
697        id
698    }
699}
700
701impl<'c, C: X11Connection> PictureWrapper<&'c C>
702{
703    /// Create a new Picture and return a Picture wrapper and a cookie.
704    ///
705    /// This is a thin wrapper around [create_picture] that allocates an id for the Picture.
706    /// This function returns the resulting `PictureWrapper` that owns the created Picture and frees
707    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
708    /// [create_picture].
709    ///
710    /// Errors can come from the call to [X11Connection::generate_id] or [create_picture].
711    pub fn create_picture_and_get_cookie(conn: &'c C, drawable: xproto::Drawable, format: Pictformat, value_list: &CreatePictureAux) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
712    {
713        let pid = conn.generate_id()?;
714        let cookie = create_picture(conn, pid, drawable, format, value_list)?;
715        Ok((Self::for_picture(conn, pid), cookie))
716    }
717}
718impl<C: X11Connection> PictureWrapper<C>
719{
720    /// Create a new Picture and return a Picture wrapper
721    ///
722    /// This is a thin wrapper around [create_picture] that allocates an id for the Picture.
723    /// This function returns the resulting `PictureWrapper` that owns the created Picture and frees
724    /// it in `Drop`.
725    ///
726    /// Errors can come from the call to [X11Connection::generate_id] or [create_picture].
727    pub fn create_picture(conn: C, drawable: xproto::Drawable, format: Pictformat, value_list: &CreatePictureAux) -> Result<Self, ReplyOrIdError>
728    {
729        let pid = conn.generate_id()?;
730        let _ = create_picture(&conn, pid, drawable, format, value_list)?;
731        Ok(Self::for_picture(conn, pid))
732    }
733}
734
735impl<'c, C: X11Connection> PictureWrapper<&'c C>
736{
737    /// Create a new Picture and return a Picture wrapper and a cookie.
738    ///
739    /// This is a thin wrapper around [create_solid_fill] that allocates an id for the Picture.
740    /// This function returns the resulting `PictureWrapper` that owns the created Picture and frees
741    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
742    /// [create_solid_fill].
743    ///
744    /// Errors can come from the call to [X11Connection::generate_id] or [create_solid_fill].
745    pub fn create_solid_fill_and_get_cookie(conn: &'c C, color: Color) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
746    {
747        let picture = conn.generate_id()?;
748        let cookie = create_solid_fill(conn, picture, color)?;
749        Ok((Self::for_picture(conn, picture), cookie))
750    }
751}
752impl<C: X11Connection> PictureWrapper<C>
753{
754    /// Create a new Picture and return a Picture wrapper
755    ///
756    /// This is a thin wrapper around [create_solid_fill] that allocates an id for the Picture.
757    /// This function returns the resulting `PictureWrapper` that owns the created Picture and frees
758    /// it in `Drop`.
759    ///
760    /// Errors can come from the call to [X11Connection::generate_id] or [create_solid_fill].
761    pub fn create_solid_fill(conn: C, color: Color) -> Result<Self, ReplyOrIdError>
762    {
763        let picture = conn.generate_id()?;
764        let _ = create_solid_fill(&conn, picture, color)?;
765        Ok(Self::for_picture(conn, picture))
766    }
767}
768
769impl<'c, C: X11Connection> PictureWrapper<&'c C>
770{
771    /// Create a new Picture and return a Picture wrapper and a cookie.
772    ///
773    /// This is a thin wrapper around [create_linear_gradient] that allocates an id for the Picture.
774    /// This function returns the resulting `PictureWrapper` that owns the created Picture and frees
775    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
776    /// [create_linear_gradient].
777    ///
778    /// Errors can come from the call to [X11Connection::generate_id] or [create_linear_gradient].
779    pub fn create_linear_gradient_and_get_cookie(conn: &'c C, p1: Pointfix, p2: Pointfix, stops: &[Fixed], colors: &[Color]) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
780    {
781        let picture = conn.generate_id()?;
782        let cookie = create_linear_gradient(conn, picture, p1, p2, stops, colors)?;
783        Ok((Self::for_picture(conn, picture), cookie))
784    }
785}
786impl<C: X11Connection> PictureWrapper<C>
787{
788    /// Create a new Picture and return a Picture wrapper
789    ///
790    /// This is a thin wrapper around [create_linear_gradient] that allocates an id for the Picture.
791    /// This function returns the resulting `PictureWrapper` that owns the created Picture and frees
792    /// it in `Drop`.
793    ///
794    /// Errors can come from the call to [X11Connection::generate_id] or [create_linear_gradient].
795    pub fn create_linear_gradient(conn: C, p1: Pointfix, p2: Pointfix, stops: &[Fixed], colors: &[Color]) -> Result<Self, ReplyOrIdError>
796    {
797        let picture = conn.generate_id()?;
798        let _ = create_linear_gradient(&conn, picture, p1, p2, stops, colors)?;
799        Ok(Self::for_picture(conn, picture))
800    }
801}
802
803impl<'c, C: X11Connection> PictureWrapper<&'c C>
804{
805    /// Create a new Picture and return a Picture wrapper and a cookie.
806    ///
807    /// This is a thin wrapper around [create_radial_gradient] that allocates an id for the Picture.
808    /// This function returns the resulting `PictureWrapper` that owns the created Picture and frees
809    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
810    /// [create_radial_gradient].
811    ///
812    /// Errors can come from the call to [X11Connection::generate_id] or [create_radial_gradient].
813    pub fn create_radial_gradient_and_get_cookie(conn: &'c C, inner: Pointfix, outer: Pointfix, inner_radius: Fixed, outer_radius: Fixed, stops: &[Fixed], colors: &[Color]) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
814    {
815        let picture = conn.generate_id()?;
816        let cookie = create_radial_gradient(conn, picture, inner, outer, inner_radius, outer_radius, stops, colors)?;
817        Ok((Self::for_picture(conn, picture), cookie))
818    }
819}
820impl<C: X11Connection> PictureWrapper<C>
821{
822    /// Create a new Picture and return a Picture wrapper
823    ///
824    /// This is a thin wrapper around [create_radial_gradient] that allocates an id for the Picture.
825    /// This function returns the resulting `PictureWrapper` that owns the created Picture and frees
826    /// it in `Drop`.
827    ///
828    /// Errors can come from the call to [X11Connection::generate_id] or [create_radial_gradient].
829    pub fn create_radial_gradient(conn: C, inner: Pointfix, outer: Pointfix, inner_radius: Fixed, outer_radius: Fixed, stops: &[Fixed], colors: &[Color]) -> Result<Self, ReplyOrIdError>
830    {
831        let picture = conn.generate_id()?;
832        let _ = create_radial_gradient(&conn, picture, inner, outer, inner_radius, outer_radius, stops, colors)?;
833        Ok(Self::for_picture(conn, picture))
834    }
835}
836
837impl<'c, C: X11Connection> PictureWrapper<&'c C>
838{
839    /// Create a new Picture and return a Picture wrapper and a cookie.
840    ///
841    /// This is a thin wrapper around [create_conical_gradient] that allocates an id for the Picture.
842    /// This function returns the resulting `PictureWrapper` that owns the created Picture and frees
843    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
844    /// [create_conical_gradient].
845    ///
846    /// Errors can come from the call to [X11Connection::generate_id] or [create_conical_gradient].
847    pub fn create_conical_gradient_and_get_cookie(conn: &'c C, center: Pointfix, angle: Fixed, stops: &[Fixed], colors: &[Color]) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
848    {
849        let picture = conn.generate_id()?;
850        let cookie = create_conical_gradient(conn, picture, center, angle, stops, colors)?;
851        Ok((Self::for_picture(conn, picture), cookie))
852    }
853}
854impl<C: X11Connection> PictureWrapper<C>
855{
856    /// Create a new Picture and return a Picture wrapper
857    ///
858    /// This is a thin wrapper around [create_conical_gradient] that allocates an id for the Picture.
859    /// This function returns the resulting `PictureWrapper` that owns the created Picture and frees
860    /// it in `Drop`.
861    ///
862    /// Errors can come from the call to [X11Connection::generate_id] or [create_conical_gradient].
863    pub fn create_conical_gradient(conn: C, center: Pointfix, angle: Fixed, stops: &[Fixed], colors: &[Color]) -> Result<Self, ReplyOrIdError>
864    {
865        let picture = conn.generate_id()?;
866        let _ = create_conical_gradient(&conn, picture, center, angle, stops, colors)?;
867        Ok(Self::for_picture(conn, picture))
868    }
869}
870
871impl<C: RequestConnection> From<&PictureWrapper<C>> for Picture {
872    fn from(from: &PictureWrapper<C>) -> Self {
873        from.1
874    }
875}
876
877impl<C: RequestConnection> Drop for PictureWrapper<C> {
878    fn drop(&mut self) {
879        let _ = free_picture(&self.0, self.1);
880    }
881}
882
883/// A RAII-like wrapper around a [Glyphset].
884///
885/// Instances of this struct represent a Glyphset that is freed in `Drop`.
886///
887/// Any errors during `Drop` are silently ignored. Most likely an error here means that your
888/// X11 connection is broken and later requests will also fail.
889#[derive(Debug)]
890pub struct GlyphsetWrapper<C: RequestConnection>(C, Glyphset);
891
892impl<C: RequestConnection> GlyphsetWrapper<C>
893{
894    /// Assume ownership of the given resource and destroy it in `Drop`.
895    pub fn for_glyphset(conn: C, id: Glyphset) -> Self {
896        GlyphsetWrapper(conn, id)
897    }
898
899    /// Get the XID of the wrapped resource
900    pub fn glyphset(&self) -> Glyphset {
901        self.1
902    }
903
904    /// Assume ownership of the XID of the wrapped resource
905    ///
906    /// This function destroys this wrapper without freeing the underlying resource.
907    pub fn into_glyphset(self) -> Glyphset {
908        let id = self.1;
909        std::mem::forget(self);
910        id
911    }
912}
913
914impl<'c, C: X11Connection> GlyphsetWrapper<&'c C>
915{
916    /// Create a new Glyphset and return a Glyphset wrapper and a cookie.
917    ///
918    /// This is a thin wrapper around [create_glyph_set] that allocates an id for the Glyphset.
919    /// This function returns the resulting `GlyphsetWrapper` that owns the created Glyphset and frees
920    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
921    /// [create_glyph_set].
922    ///
923    /// Errors can come from the call to [X11Connection::generate_id] or [create_glyph_set].
924    pub fn create_glyph_set_and_get_cookie(conn: &'c C, format: Pictformat) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
925    {
926        let gsid = conn.generate_id()?;
927        let cookie = create_glyph_set(conn, gsid, format)?;
928        Ok((Self::for_glyphset(conn, gsid), cookie))
929    }
930}
931impl<C: X11Connection> GlyphsetWrapper<C>
932{
933    /// Create a new Glyphset and return a Glyphset wrapper
934    ///
935    /// This is a thin wrapper around [create_glyph_set] that allocates an id for the Glyphset.
936    /// This function returns the resulting `GlyphsetWrapper` that owns the created Glyphset and frees
937    /// it in `Drop`.
938    ///
939    /// Errors can come from the call to [X11Connection::generate_id] or [create_glyph_set].
940    pub fn create_glyph_set(conn: C, format: Pictformat) -> Result<Self, ReplyOrIdError>
941    {
942        let gsid = conn.generate_id()?;
943        let _ = create_glyph_set(&conn, gsid, format)?;
944        Ok(Self::for_glyphset(conn, gsid))
945    }
946}
947
948impl<C: RequestConnection> From<&GlyphsetWrapper<C>> for Glyphset {
949    fn from(from: &GlyphsetWrapper<C>) -> Self {
950        from.1
951    }
952}
953
954impl<C: RequestConnection> Drop for GlyphsetWrapper<C> {
955    fn drop(&mut self) {
956        let _ = free_glyph_set(&self.0, self.1);
957    }
958}