x11rb/protocol/
xproto.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the core X11 protocol.
5//!
6//! For more documentation on the X11 protocol, see the
7//! [protocol reference manual](https://www.x.org/releases/X11R7.6/doc/xproto/x11protocol.html).
8//! This is especially recommended for looking up the exact semantics of
9//! specific errors, events, or requests.
10
11#![allow(clippy::too_many_arguments)]
12
13#[allow(unused_imports)]
14use std::borrow::Cow;
15#[allow(unused_imports)]
16use std::convert::TryInto;
17#[allow(unused_imports)]
18use crate::utils::RawFdContainer;
19#[allow(unused_imports)]
20use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd};
21use std::io::IoSlice;
22use crate::connection::RequestConnection;
23#[allow(unused_imports)]
24use crate::connection::Connection as X11Connection;
25#[allow(unused_imports)]
26use crate::cookie::{Cookie, CookieWithFds, VoidCookie};
27use crate::cookie::ListFontsWithInfoCookie;
28use crate::errors::ConnectionError;
29#[allow(unused_imports)]
30use crate::errors::ReplyOrIdError;
31
32pub use x11rb_protocol::protocol::xproto::*;
33
34/// Creates a window.
35///
36/// Creates an unmapped window as child of the specified `parent` window. A
37/// CreateNotify event will be generated. The new window is placed on top in the
38/// stacking order with respect to siblings.
39///
40/// The coordinate system has the X axis horizontal and the Y axis vertical with
41/// the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms
42/// of pixels, and coincide with pixel centers. Each window and pixmap has its own
43/// coordinate system. For a window, the origin is inside the border at the inside,
44/// upper-left corner.
45///
46/// The created window is not yet displayed (mapped), call `xcb_map_window` to
47/// display it.
48///
49/// The created window will initially use the same cursor as its parent.
50///
51/// # Fields
52///
53/// * `wid` - The ID with which you will refer to the new window, created by
54/// `xcb_generate_id`.
55/// * `depth` - Specifies the new window's depth (TODO: what unit?).
56///
57/// The special value `XCB_COPY_FROM_PARENT` means the depth is taken from the
58/// `parent` window.
59/// * `visual` - Specifies the id for the new window's visual.
60///
61/// The special value `XCB_COPY_FROM_PARENT` means the visual is taken from the
62/// `parent` window.
63/// * `class` -
64/// * `parent` - The parent window of the new window.
65/// * `border_width` - TODO:
66///
67/// Must be zero if the `class` is `InputOnly` or a `xcb_match_error_t` occurs.
68/// * `x` - The X coordinate of the new window.
69/// * `y` - The Y coordinate of the new window.
70/// * `width` - The width of the new window.
71/// * `height` - The height of the new window.
72///
73/// # Errors
74///
75/// * `Colormap` - TODO: reasons?
76/// * `Match` - TODO: reasons?
77/// * `Cursor` - TODO: reasons?
78/// * `Pixmap` - TODO: reasons?
79/// * `Value` - TODO: reasons?
80/// * `Window` - TODO: reasons?
81/// * `Alloc` - The X server could not allocate the requested resources (no memory?).
82///
83/// # See
84///
85/// * `xcb_generate_id`: function
86/// * `MapWindow`: request
87/// * `CreateNotify`: event
88pub fn create_window<'c, 'input, Conn>(conn: &'c Conn, depth: u8, wid: Window, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, class: WindowClass, visual: Visualid, value_list: &'input CreateWindowAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
89where
90    Conn: RequestConnection + ?Sized,
91{
92    let request0 = CreateWindowRequest {
93        depth,
94        wid,
95        parent,
96        x,
97        y,
98        width,
99        height,
100        border_width,
101        class,
102        visual,
103        value_list: Cow::Borrowed(value_list),
104    };
105    let (bytes, fds) = request0.serialize();
106    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
107    assert_eq!(slices.len(), bytes.len());
108    conn.send_request_without_reply(&slices, fds)
109}
110
111/// change window attributes.
112///
113/// Changes the attributes specified by `value_mask` for the specified `window`.
114///
115/// # Fields
116///
117/// * `window` - The window to change.
118/// * `value_mask` -
119/// * `value_list` - Values for each of the attributes specified in the bitmask `value_mask`. The
120/// order has to correspond to the order of possible `value_mask` bits. See the
121/// example.
122///
123/// # Errors
124///
125/// * `Access` - TODO: reasons?
126/// * `Colormap` - TODO: reasons?
127/// * `Cursor` - TODO: reasons?
128/// * `Match` - TODO: reasons?
129/// * `Pixmap` - TODO: reasons?
130/// * `Value` - TODO: reasons?
131/// * `Window` - The specified `window` does not exist.
132pub fn change_window_attributes<'c, 'input, Conn>(conn: &'c Conn, window: Window, value_list: &'input ChangeWindowAttributesAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
133where
134    Conn: RequestConnection + ?Sized,
135{
136    let request0 = ChangeWindowAttributesRequest {
137        window,
138        value_list: Cow::Borrowed(value_list),
139    };
140    let (bytes, fds) = request0.serialize();
141    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
142    assert_eq!(slices.len(), bytes.len());
143    conn.send_request_without_reply(&slices, fds)
144}
145
146/// Gets window attributes.
147///
148/// Gets the current attributes for the specified `window`.
149///
150/// # Fields
151///
152/// * `window` - The window to get the attributes from.
153///
154/// # Errors
155///
156/// * `Window` - The specified `window` does not exist.
157/// * `Drawable` - TODO: reasons?
158pub fn get_window_attributes<Conn>(conn: &Conn, window: Window) -> Result<Cookie<'_, Conn, GetWindowAttributesReply>, ConnectionError>
159where
160    Conn: RequestConnection + ?Sized,
161{
162    let request0 = GetWindowAttributesRequest {
163        window,
164    };
165    let (bytes, fds) = request0.serialize();
166    let slices = [IoSlice::new(&bytes[0])];
167    assert_eq!(slices.len(), bytes.len());
168    conn.send_request_with_reply(&slices, fds)
169}
170
171/// Destroys a window.
172///
173/// Destroys the specified window and all of its subwindows. A DestroyNotify event
174/// is generated for each destroyed window (a DestroyNotify event is first generated
175/// for any given window's inferiors). If the window was mapped, it will be
176/// automatically unmapped before destroying.
177///
178/// Calling DestroyWindow on the root window will do nothing.
179///
180/// # Fields
181///
182/// * `window` - The window to destroy.
183///
184/// # Errors
185///
186/// * `Window` - The specified window does not exist.
187///
188/// # See
189///
190/// * `DestroyNotify`: event
191/// * `MapWindow`: request
192/// * `UnmapWindow`: request
193pub fn destroy_window<Conn>(conn: &Conn, window: Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
194where
195    Conn: RequestConnection + ?Sized,
196{
197    let request0 = DestroyWindowRequest {
198        window,
199    };
200    let (bytes, fds) = request0.serialize();
201    let slices = [IoSlice::new(&bytes[0])];
202    assert_eq!(slices.len(), bytes.len());
203    conn.send_request_without_reply(&slices, fds)
204}
205
206pub fn destroy_subwindows<Conn>(conn: &Conn, window: Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
207where
208    Conn: RequestConnection + ?Sized,
209{
210    let request0 = DestroySubwindowsRequest {
211        window,
212    };
213    let (bytes, fds) = request0.serialize();
214    let slices = [IoSlice::new(&bytes[0])];
215    assert_eq!(slices.len(), bytes.len());
216    conn.send_request_without_reply(&slices, fds)
217}
218
219/// Changes a client's save set.
220///
221/// TODO: explain what the save set is for.
222///
223/// This function either adds or removes the specified window to the client's (your
224/// application's) save set.
225///
226/// # Fields
227///
228/// * `mode` - Insert to add the specified window to the save set or Delete to delete it from the save set.
229/// * `window` - The window to add or delete to/from your save set.
230///
231/// # Errors
232///
233/// * `Match` - You created the specified window. This does not make sense, you can only add
234/// windows created by other clients to your save set.
235/// * `Value` - You specified an invalid mode.
236/// * `Window` - The specified window does not exist.
237///
238/// # See
239///
240/// * `ReparentWindow`: request
241pub fn change_save_set<Conn>(conn: &Conn, mode: SetMode, window: Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
242where
243    Conn: RequestConnection + ?Sized,
244{
245    let request0 = ChangeSaveSetRequest {
246        mode,
247        window,
248    };
249    let (bytes, fds) = request0.serialize();
250    let slices = [IoSlice::new(&bytes[0])];
251    assert_eq!(slices.len(), bytes.len());
252    conn.send_request_without_reply(&slices, fds)
253}
254
255/// Reparents a window.
256///
257/// Makes the specified window a child of the specified parent window. If the
258/// window is mapped, it will automatically be unmapped before reparenting and
259/// re-mapped after reparenting. The window is placed in the stacking order on top
260/// with respect to sibling windows.
261///
262/// After reparenting, a ReparentNotify event is generated.
263///
264/// # Fields
265///
266/// * `window` - The window to reparent.
267/// * `parent` - The new parent of the window.
268/// * `x` - The X position of the window within its new parent.
269/// * `y` - The Y position of the window within its new parent.
270///
271/// # Errors
272///
273/// * `Match` - The new parent window is not on the same screen as the old parent window.
274/// 
275/// The new parent window is the specified window or an inferior of the specified window.
276/// 
277/// The new parent is InputOnly and the window is not.
278/// 
279/// The specified window has a ParentRelative background and the new parent window is not the same depth as the specified window.
280/// * `Window` - The specified window does not exist.
281///
282/// # See
283///
284/// * `ReparentNotify`: event
285/// * `MapWindow`: request
286/// * `UnmapWindow`: request
287pub fn reparent_window<Conn>(conn: &Conn, window: Window, parent: Window, x: i16, y: i16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
288where
289    Conn: RequestConnection + ?Sized,
290{
291    let request0 = ReparentWindowRequest {
292        window,
293        parent,
294        x,
295        y,
296    };
297    let (bytes, fds) = request0.serialize();
298    let slices = [IoSlice::new(&bytes[0])];
299    assert_eq!(slices.len(), bytes.len());
300    conn.send_request_without_reply(&slices, fds)
301}
302
303/// Makes a window visible.
304///
305/// Maps the specified window. This means making the window visible (as long as its
306/// parent is visible).
307///
308/// This MapWindow request will be translated to a MapRequest request if a window
309/// manager is running. The window manager then decides to either map the window or
310/// not. Set the override-redirect window attribute to true if you want to bypass
311/// this mechanism.
312///
313/// If the window manager decides to map the window (or if no window manager is
314/// running), a MapNotify event is generated.
315///
316/// If the window becomes viewable and no earlier contents for it are remembered,
317/// the X server tiles the window with its background. If the window's background
318/// is undefined, the existing screen contents are not altered, and the X server
319/// generates zero or more Expose events.
320///
321/// If the window type is InputOutput, an Expose event will be generated when the
322/// window becomes visible. The normal response to an Expose event should be to
323/// repaint the window.
324///
325/// # Fields
326///
327/// * `window` - The window to make visible.
328///
329/// # Errors
330///
331/// * `Match` - The specified window does not exist.
332///
333/// # See
334///
335/// * `MapNotify`: event
336/// * `Expose`: event
337/// * `UnmapWindow`: request
338pub fn map_window<Conn>(conn: &Conn, window: Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
339where
340    Conn: RequestConnection + ?Sized,
341{
342    let request0 = MapWindowRequest {
343        window,
344    };
345    let (bytes, fds) = request0.serialize();
346    let slices = [IoSlice::new(&bytes[0])];
347    assert_eq!(slices.len(), bytes.len());
348    conn.send_request_without_reply(&slices, fds)
349}
350
351pub fn map_subwindows<Conn>(conn: &Conn, window: Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
352where
353    Conn: RequestConnection + ?Sized,
354{
355    let request0 = MapSubwindowsRequest {
356        window,
357    };
358    let (bytes, fds) = request0.serialize();
359    let slices = [IoSlice::new(&bytes[0])];
360    assert_eq!(slices.len(), bytes.len());
361    conn.send_request_without_reply(&slices, fds)
362}
363
364/// Makes a window invisible.
365///
366/// Unmaps the specified window. This means making the window invisible (and all
367/// its child windows).
368///
369/// Unmapping a window leads to the `UnmapNotify` event being generated. Also,
370/// `Expose` events are generated for formerly obscured windows.
371///
372/// # Fields
373///
374/// * `window` - The window to make invisible.
375///
376/// # Errors
377///
378/// * `Window` - The specified window does not exist.
379///
380/// # See
381///
382/// * `UnmapNotify`: event
383/// * `Expose`: event
384/// * `MapWindow`: request
385pub fn unmap_window<Conn>(conn: &Conn, window: Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
386where
387    Conn: RequestConnection + ?Sized,
388{
389    let request0 = UnmapWindowRequest {
390        window,
391    };
392    let (bytes, fds) = request0.serialize();
393    let slices = [IoSlice::new(&bytes[0])];
394    assert_eq!(slices.len(), bytes.len());
395    conn.send_request_without_reply(&slices, fds)
396}
397
398pub fn unmap_subwindows<Conn>(conn: &Conn, window: Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
399where
400    Conn: RequestConnection + ?Sized,
401{
402    let request0 = UnmapSubwindowsRequest {
403        window,
404    };
405    let (bytes, fds) = request0.serialize();
406    let slices = [IoSlice::new(&bytes[0])];
407    assert_eq!(slices.len(), bytes.len());
408    conn.send_request_without_reply(&slices, fds)
409}
410
411/// Configures window attributes.
412///
413/// Configures a window's size, position, border width and stacking order.
414///
415/// # Fields
416///
417/// * `window` - The window to configure.
418/// * `value_mask` - Bitmask of attributes to change.
419/// * `value_list` - New values, corresponding to the attributes in value_mask. The order has to
420/// correspond to the order of possible `value_mask` bits. See the example.
421///
422/// # Errors
423///
424/// * `Match` - You specified a Sibling without also specifying StackMode or the window is not
425/// actually a Sibling.
426/// * `Window` - The specified window does not exist. TODO: any other reason?
427/// * `Value` - TODO: reasons?
428///
429/// # See
430///
431/// * `MapNotify`: event
432/// * `Expose`: event
433///
434/// # Example
435///
436/// ```text
437/// /*
438///  * Configures the given window to the left upper corner
439///  * with a size of 1024x768 pixels.
440///  *
441///  */
442/// void my_example(xcb_connection_t *c, xcb_window_t window) {
443///     uint16_t mask = 0;
444///
445///     mask |= XCB_CONFIG_WINDOW_X;
446///     mask |= XCB_CONFIG_WINDOW_Y;
447///     mask |= XCB_CONFIG_WINDOW_WIDTH;
448///     mask |= XCB_CONFIG_WINDOW_HEIGHT;
449///
450///     const uint32_t values[] = {
451///         0,    /* x */
452///         0,    /* y */
453///         1024, /* width */
454///         768   /* height */
455///     };
456///
457///     xcb_configure_window(c, window, mask, values);
458///     xcb_flush(c);
459/// }
460/// ```
461pub fn configure_window<'c, 'input, Conn>(conn: &'c Conn, window: Window, value_list: &'input ConfigureWindowAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
462where
463    Conn: RequestConnection + ?Sized,
464{
465    let request0 = ConfigureWindowRequest {
466        window,
467        value_list: Cow::Borrowed(value_list),
468    };
469    let (bytes, fds) = request0.serialize();
470    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
471    assert_eq!(slices.len(), bytes.len());
472    conn.send_request_without_reply(&slices, fds)
473}
474
475/// Change window stacking order.
476///
477/// If `direction` is `XCB_CIRCULATE_RAISE_LOWEST`, the lowest mapped child (if
478/// any) will be raised to the top of the stack.
479///
480/// If `direction` is `XCB_CIRCULATE_LOWER_HIGHEST`, the highest mapped child will
481/// be lowered to the bottom of the stack.
482///
483/// # Fields
484///
485/// * `direction` -
486/// * `window` - The window to raise/lower (depending on `direction`).
487///
488/// # Errors
489///
490/// * `Window` - The specified `window` does not exist.
491/// * `Value` - The specified `direction` is invalid.
492pub fn circulate_window<Conn>(conn: &Conn, direction: Circulate, window: Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
493where
494    Conn: RequestConnection + ?Sized,
495{
496    let request0 = CirculateWindowRequest {
497        direction,
498        window,
499    };
500    let (bytes, fds) = request0.serialize();
501    let slices = [IoSlice::new(&bytes[0])];
502    assert_eq!(slices.len(), bytes.len());
503    conn.send_request_without_reply(&slices, fds)
504}
505
506/// Get current window geometry.
507///
508/// Gets the current geometry of the specified drawable (either `Window` or `Pixmap`).
509///
510/// # Fields
511///
512/// * `drawable` - The drawable (`Window` or `Pixmap`) of which the geometry will be received.
513///
514/// # Errors
515///
516/// * `Drawable` - TODO: reasons?
517/// * `Window` - TODO: reasons?
518///
519/// # See
520///
521/// * `xwininfo`: program
522///
523/// # Example
524///
525/// ```text
526/// /*
527///  * Displays the x and y position of the given window.
528///  *
529///  */
530/// void my_example(xcb_connection_t *c, xcb_window_t window) {
531///     xcb_get_geometry_cookie_t cookie;
532///     xcb_get_geometry_reply_t *reply;
533///
534///     cookie = xcb_get_geometry(c, window);
535///     /* ... do other work here if possible ... */
536///     if ((reply = xcb_get_geometry_reply(c, cookie, NULL))) {
537///         printf("This window is at %d, %d\\n", reply->x, reply->y);
538///     }
539///     free(reply);
540/// }
541/// ```
542pub fn get_geometry<Conn>(conn: &Conn, drawable: Drawable) -> Result<Cookie<'_, Conn, GetGeometryReply>, ConnectionError>
543where
544    Conn: RequestConnection + ?Sized,
545{
546    let request0 = GetGeometryRequest {
547        drawable,
548    };
549    let (bytes, fds) = request0.serialize();
550    let slices = [IoSlice::new(&bytes[0])];
551    assert_eq!(slices.len(), bytes.len());
552    conn.send_request_with_reply(&slices, fds)
553}
554
555/// query the window tree.
556///
557/// Gets the root window ID, parent window ID and list of children windows for the
558/// specified `window`. The children are listed in bottom-to-top stacking order.
559///
560/// # Fields
561///
562/// * `window` - The `window` to query.
563///
564/// # See
565///
566/// * `xwininfo`: program
567///
568/// # Example
569///
570/// ```text
571/// /*
572///  * Displays the root, parent and children of the specified window.
573///  *
574///  */
575/// void my_example(xcb_connection_t *conn, xcb_window_t window) {
576///     xcb_query_tree_cookie_t cookie;
577///     xcb_query_tree_reply_t *reply;
578///
579///     cookie = xcb_query_tree(conn, window);
580///     if ((reply = xcb_query_tree_reply(conn, cookie, NULL))) {
581///         printf("root = 0x%08x\\n", reply->root);
582///         printf("parent = 0x%08x\\n", reply->parent);
583///
584///         xcb_window_t *children = xcb_query_tree_children(reply);
585///         for (int i = 0; i < xcb_query_tree_children_length(reply); i++)
586///             printf("child window = 0x%08x\\n", children[i]);
587///
588///         free(reply);
589///     }
590/// }
591/// ```
592pub fn query_tree<Conn>(conn: &Conn, window: Window) -> Result<Cookie<'_, Conn, QueryTreeReply>, ConnectionError>
593where
594    Conn: RequestConnection + ?Sized,
595{
596    let request0 = QueryTreeRequest {
597        window,
598    };
599    let (bytes, fds) = request0.serialize();
600    let slices = [IoSlice::new(&bytes[0])];
601    assert_eq!(slices.len(), bytes.len());
602    conn.send_request_with_reply(&slices, fds)
603}
604
605/// Get atom identifier by name.
606///
607/// Retrieves the identifier (xcb_atom_t TODO) for the atom with the specified
608/// name. Atoms are used in protocols like EWMH, for example to store window titles
609/// (`_NET_WM_NAME` atom) as property of a window.
610///
611/// If `only_if_exists` is 0, the atom will be created if it does not already exist.
612/// If `only_if_exists` is 1, `XCB_ATOM_NONE` will be returned if the atom does
613/// not yet exist.
614///
615/// # Fields
616///
617/// * `name_len` - The length of the following `name`.
618/// * `name` - The name of the atom.
619/// * `only_if_exists` - Return a valid atom id only if the atom already exists.
620///
621/// # Errors
622///
623/// * `Alloc` - TODO: reasons?
624/// * `Value` - A value other than 0 or 1 was specified for `only_if_exists`.
625///
626/// # See
627///
628/// * `xlsatoms`: program
629/// * `GetAtomName`: request
630///
631/// # Example
632///
633/// ```text
634/// /*
635///  * Resolves the _NET_WM_NAME atom.
636///  *
637///  */
638/// void my_example(xcb_connection_t *c) {
639///     xcb_intern_atom_cookie_t cookie;
640///     xcb_intern_atom_reply_t *reply;
641///
642///     cookie = xcb_intern_atom(c, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME");
643///     /* ... do other work here if possible ... */
644///     if ((reply = xcb_intern_atom_reply(c, cookie, NULL))) {
645///         printf("The _NET_WM_NAME atom has ID %u\n", reply->atom);
646///         free(reply);
647///     }
648/// }
649/// ```
650pub fn intern_atom<'c, 'input, Conn>(conn: &'c Conn, only_if_exists: bool, name: &'input [u8]) -> Result<Cookie<'c, Conn, InternAtomReply>, ConnectionError>
651where
652    Conn: RequestConnection + ?Sized,
653{
654    let request0 = InternAtomRequest {
655        only_if_exists,
656        name: Cow::Borrowed(name),
657    };
658    let (bytes, fds) = request0.serialize();
659    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
660    assert_eq!(slices.len(), bytes.len());
661    conn.send_request_with_reply(&slices, fds)
662}
663
664pub fn get_atom_name<Conn>(conn: &Conn, atom: Atom) -> Result<Cookie<'_, Conn, GetAtomNameReply>, ConnectionError>
665where
666    Conn: RequestConnection + ?Sized,
667{
668    let request0 = GetAtomNameRequest {
669        atom,
670    };
671    let (bytes, fds) = request0.serialize();
672    let slices = [IoSlice::new(&bytes[0])];
673    assert_eq!(slices.len(), bytes.len());
674    conn.send_request_with_reply(&slices, fds)
675}
676
677/// Changes a window property.
678///
679/// Sets or updates a property on the specified `window`. Properties are for
680/// example the window title (`WM_NAME`) or its minimum size (`WM_NORMAL_HINTS`).
681/// Protocols such as EWMH also use properties - for example EWMH defines the
682/// window title, encoded as UTF-8 string, in the `_NET_WM_NAME` property.
683///
684/// # Fields
685///
686/// * `window` - The window whose property you want to change.
687/// * `mode` -
688/// * `property` - The property you want to change (an atom).
689/// * `type` - The type of the property you want to change (an atom).
690/// * `format` - Specifies whether the data should be viewed as a list of 8-bit, 16-bit or
691/// 32-bit quantities. Possible values are 8, 16 and 32. This information allows
692/// the X server to correctly perform byte-swap operations as necessary.
693/// * `data_len` - Specifies the number of elements (see `format`).
694/// * `data` - The property data.
695///
696/// # Errors
697///
698/// * `Match` - TODO: reasons?
699/// * `Value` - TODO: reasons?
700/// * `Window` - The specified `window` does not exist.
701/// * `Atom` - `property` or `type` do not refer to a valid atom.
702/// * `Alloc` - The X server could not store the property (no memory?).
703///
704/// # See
705///
706/// * `InternAtom`: request
707/// * `xprop`: program
708///
709/// # Example
710///
711/// ```text
712/// /*
713///  * Sets the WM_NAME property of the window to "XCB Example".
714///  *
715///  */
716/// void my_example(xcb_connection_t *conn, xcb_window_t window) {
717///     xcb_change_property(conn,
718///         XCB_PROP_MODE_REPLACE,
719///         window,
720///         XCB_ATOM_WM_NAME,
721///         XCB_ATOM_STRING,
722///         8,
723///         strlen("XCB Example"),
724///         "XCB Example");
725///     xcb_flush(conn);
726/// }
727/// ```
728pub fn change_property<'c, 'input, Conn, A, B>(conn: &'c Conn, mode: PropMode, window: Window, property: A, type_: B, format: u8, data_len: u32, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
729where
730    Conn: RequestConnection + ?Sized,
731    A: Into<Atom>,
732    B: Into<Atom>,
733{
734    let property: Atom = property.into();
735    let type_: Atom = type_.into();
736    let request0 = ChangePropertyRequest {
737        mode,
738        window,
739        property,
740        type_,
741        format,
742        data_len,
743        data: Cow::Borrowed(data),
744    };
745    let (bytes, fds) = request0.serialize();
746    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
747    assert_eq!(slices.len(), bytes.len());
748    conn.send_request_without_reply(&slices, fds)
749}
750
751pub fn delete_property<Conn>(conn: &Conn, window: Window, property: Atom) -> Result<VoidCookie<'_, Conn>, ConnectionError>
752where
753    Conn: RequestConnection + ?Sized,
754{
755    let request0 = DeletePropertyRequest {
756        window,
757        property,
758    };
759    let (bytes, fds) = request0.serialize();
760    let slices = [IoSlice::new(&bytes[0])];
761    assert_eq!(slices.len(), bytes.len());
762    conn.send_request_without_reply(&slices, fds)
763}
764
765/// Gets a window property.
766///
767/// Gets the specified `property` from the specified `window`. Properties are for
768/// example the window title (`WM_NAME`) or its minimum size (`WM_NORMAL_HINTS`).
769/// Protocols such as EWMH also use properties - for example EWMH defines the
770/// window title, encoded as UTF-8 string, in the `_NET_WM_NAME` property.
771///
772/// TODO: talk about `type`
773///
774/// TODO: talk about `delete`
775///
776/// TODO: talk about the offset/length thing. what's a valid use case?
777///
778/// # Fields
779///
780/// * `window` - The window whose property you want to get.
781/// * `delete` - Whether the property should actually be deleted. For deleting a property, the
782/// specified `type` has to match the actual property type.
783/// * `property` - The property you want to get (an atom).
784/// * `type` - The type of the property you want to get (an atom).
785/// * `long_offset` - Specifies the offset (in 32-bit multiples) in the specified property where the
786/// data is to be retrieved.
787/// * `long_length` - Specifies how many 32-bit multiples of data should be retrieved (e.g. if you
788/// set `long_length` to 4, you will receive 16 bytes of data).
789///
790/// # Errors
791///
792/// * `Window` - The specified `window` does not exist.
793/// * `Atom` - `property` or `type` do not refer to a valid atom.
794/// * `Value` - The specified `long_offset` is beyond the actual property length (e.g. the
795/// property has a length of 3 bytes and you are setting `long_offset` to 1,
796/// resulting in a byte offset of 4).
797///
798/// # See
799///
800/// * `InternAtom`: request
801/// * `xprop`: program
802///
803/// # Example
804///
805/// ```text
806/// /*
807///  * Prints the WM_NAME property of the window.
808///  *
809///  */
810/// void my_example(xcb_connection_t *c, xcb_window_t window) {
811///     xcb_get_property_cookie_t cookie;
812///     xcb_get_property_reply_t *reply;
813///
814///     /* These atoms are predefined in the X11 protocol. */
815///     xcb_atom_t property = XCB_ATOM_WM_NAME;
816///     xcb_atom_t type = XCB_ATOM_STRING;
817///
818///     // TODO: a reasonable long_length for WM_NAME?
819///     cookie = xcb_get_property(c, 0, window, property, type, 0, 0);
820///     if ((reply = xcb_get_property_reply(c, cookie, NULL))) {
821///         int len = xcb_get_property_value_length(reply);
822///         if (len == 0) {
823///             printf("TODO\\n");
824///             free(reply);
825///             return;
826///         }
827///         printf("WM_NAME is %.*s\\n", len,
828///                (char*)xcb_get_property_value(reply));
829///     }
830///     free(reply);
831/// }
832/// ```
833pub fn get_property<Conn, A, B>(conn: &Conn, delete: bool, window: Window, property: A, type_: B, long_offset: u32, long_length: u32) -> Result<Cookie<'_, Conn, GetPropertyReply>, ConnectionError>
834where
835    Conn: RequestConnection + ?Sized,
836    A: Into<Atom>,
837    B: Into<Atom>,
838{
839    let property: Atom = property.into();
840    let type_: Atom = type_.into();
841    let request0 = GetPropertyRequest {
842        delete,
843        window,
844        property,
845        type_,
846        long_offset,
847        long_length,
848    };
849    let (bytes, fds) = request0.serialize();
850    let slices = [IoSlice::new(&bytes[0])];
851    assert_eq!(slices.len(), bytes.len());
852    conn.send_request_with_reply(&slices, fds)
853}
854
855pub fn list_properties<Conn>(conn: &Conn, window: Window) -> Result<Cookie<'_, Conn, ListPropertiesReply>, ConnectionError>
856where
857    Conn: RequestConnection + ?Sized,
858{
859    let request0 = ListPropertiesRequest {
860        window,
861    };
862    let (bytes, fds) = request0.serialize();
863    let slices = [IoSlice::new(&bytes[0])];
864    assert_eq!(slices.len(), bytes.len());
865    conn.send_request_with_reply(&slices, fds)
866}
867
868/// Sets the owner of a selection.
869///
870/// Makes `window` the owner of the selection `selection` and updates the
871/// last-change time of the specified selection.
872///
873/// TODO: briefly explain what a selection is.
874///
875/// # Fields
876///
877/// * `selection` - The selection.
878/// * `owner` - The new owner of the selection.
879///
880/// The special value `XCB_NONE` means that the selection will have no owner.
881/// * `time` - Timestamp to avoid race conditions when running X over the network.
882///
883/// The selection will not be changed if `time` is earlier than the current
884/// last-change time of the `selection` or is later than the current X server time.
885/// Otherwise, the last-change time is set to the specified time.
886///
887/// The special value `XCB_CURRENT_TIME` will be replaced with the current server
888/// time.
889///
890/// # Errors
891///
892/// * `Atom` - `selection` does not refer to a valid atom.
893///
894/// # See
895///
896/// * `SetSelectionOwner`: request
897pub fn set_selection_owner<Conn, A, B>(conn: &Conn, owner: A, selection: Atom, time: B) -> Result<VoidCookie<'_, Conn>, ConnectionError>
898where
899    Conn: RequestConnection + ?Sized,
900    A: Into<Window>,
901    B: Into<Timestamp>,
902{
903    let owner: Window = owner.into();
904    let time: Timestamp = time.into();
905    let request0 = SetSelectionOwnerRequest {
906        owner,
907        selection,
908        time,
909    };
910    let (bytes, fds) = request0.serialize();
911    let slices = [IoSlice::new(&bytes[0])];
912    assert_eq!(slices.len(), bytes.len());
913    conn.send_request_without_reply(&slices, fds)
914}
915
916/// Gets the owner of a selection.
917///
918/// Gets the owner of the specified selection.
919///
920/// TODO: briefly explain what a selection is.
921///
922/// # Fields
923///
924/// * `selection` - The selection.
925///
926/// # Errors
927///
928/// * `Atom` - `selection` does not refer to a valid atom.
929///
930/// # See
931///
932/// * `SetSelectionOwner`: request
933pub fn get_selection_owner<Conn>(conn: &Conn, selection: Atom) -> Result<Cookie<'_, Conn, GetSelectionOwnerReply>, ConnectionError>
934where
935    Conn: RequestConnection + ?Sized,
936{
937    let request0 = GetSelectionOwnerRequest {
938        selection,
939    };
940    let (bytes, fds) = request0.serialize();
941    let slices = [IoSlice::new(&bytes[0])];
942    assert_eq!(slices.len(), bytes.len());
943    conn.send_request_with_reply(&slices, fds)
944}
945
946pub fn convert_selection<Conn, A, B>(conn: &Conn, requestor: Window, selection: Atom, target: Atom, property: A, time: B) -> Result<VoidCookie<'_, Conn>, ConnectionError>
947where
948    Conn: RequestConnection + ?Sized,
949    A: Into<Atom>,
950    B: Into<Timestamp>,
951{
952    let property: Atom = property.into();
953    let time: Timestamp = time.into();
954    let request0 = ConvertSelectionRequest {
955        requestor,
956        selection,
957        target,
958        property,
959        time,
960    };
961    let (bytes, fds) = request0.serialize();
962    let slices = [IoSlice::new(&bytes[0])];
963    assert_eq!(slices.len(), bytes.len());
964    conn.send_request_without_reply(&slices, fds)
965}
966
967/// send an event.
968///
969/// Identifies the `destination` window, determines which clients should receive
970/// the specified event and ignores any active grabs.
971///
972/// The `event` must be one of the core events or an event defined by an extension,
973/// so that the X server can correctly byte-swap the contents as necessary. The
974/// contents of `event` are otherwise unaltered and unchecked except for the
975/// `send_event` field which is forced to 'true'.
976///
977/// # Fields
978///
979/// * `destination` - The window to send this event to. Every client which selects any event within
980/// `event_mask` on `destination` will get the event.
981///
982/// The special value `XCB_SEND_EVENT_DEST_POINTER_WINDOW` refers to the window
983/// that contains the mouse pointer.
984///
985/// The special value `XCB_SEND_EVENT_DEST_ITEM_FOCUS` refers to the window which
986/// has the keyboard focus.
987/// * `event_mask` - Event_mask for determining which clients should receive the specified event.
988/// See `destination` and `propagate`.
989/// * `propagate` - If `propagate` is true and no clients have selected any event on `destination`,
990/// the destination is replaced with the closest ancestor of `destination` for
991/// which some client has selected a type in `event_mask` and for which no
992/// intervening window has that type in its do-not-propagate-mask. If no such
993/// window exists or if the window is an ancestor of the focus window and
994/// `InputFocus` was originally specified as the destination, the event is not sent
995/// to any clients. Otherwise, the event is reported to every client selecting on
996/// the final destination any of the types specified in `event_mask`.
997/// * `event` - The event to send to the specified `destination`.
998///
999/// # Errors
1000///
1001/// * `Window` - The specified `destination` window does not exist.
1002/// * `Value` - The given `event` is neither a core event nor an event defined by an extension.
1003///
1004/// # See
1005///
1006/// * `ConfigureNotify`: event
1007///
1008/// # Example
1009///
1010/// ```text
1011/// /*
1012///  * Tell the given window that it was configured to a size of 800x600 pixels.
1013///  *
1014///  */
1015/// void my_example(xcb_connection_t *conn, xcb_window_t window) {
1016///     /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
1017///      * In order to properly initialize these bytes, we allocate 32 bytes even
1018///      * though we only need less for an xcb_configure_notify_event_t */
1019///     xcb_configure_notify_event_t *event = calloc(32, 1);
1020///
1021///     event->event = window;
1022///     event->window = window;
1023///     event->response_type = XCB_CONFIGURE_NOTIFY;
1024///
1025///     event->x = 0;
1026///     event->y = 0;
1027///     event->width = 800;
1028///     event->height = 600;
1029///
1030///     event->border_width = 0;
1031///     event->above_sibling = XCB_NONE;
1032///     event->override_redirect = false;
1033///
1034///     xcb_send_event(conn, false, window, XCB_EVENT_MASK_STRUCTURE_NOTIFY,
1035///                    (char*)event);
1036///     xcb_flush(conn);
1037///     free(event);
1038/// }
1039/// ```
1040pub fn send_event<Conn, A, B>(conn: &Conn, propagate: bool, destination: A, event_mask: EventMask, event: B) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1041where
1042    Conn: RequestConnection + ?Sized,
1043    A: Into<Window>,
1044    B: Into<[u8; 32]>,
1045{
1046    let destination: Window = destination.into();
1047    let event = Cow::Owned(event.into());
1048    let request0 = SendEventRequest {
1049        propagate,
1050        destination,
1051        event_mask,
1052        event,
1053    };
1054    let (bytes, fds) = request0.serialize();
1055    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1])];
1056    assert_eq!(slices.len(), bytes.len());
1057    conn.send_request_without_reply(&slices, fds)
1058}
1059
1060/// Grab the pointer.
1061///
1062/// Actively grabs control of the pointer. Further pointer events are reported only to the grabbing client. Overrides any active pointer grab by this client.
1063///
1064/// # Fields
1065///
1066/// * `event_mask` - Specifies which pointer events are reported to the client.
1067///
1068/// TODO: which values?
1069/// * `confine_to` - Specifies the window to confine the pointer in (the user will not be able to
1070/// move the pointer out of that window).
1071///
1072/// The special value `XCB_NONE` means don't confine the pointer.
1073/// * `cursor` - Specifies the cursor that should be displayed or `XCB_NONE` to not change the
1074/// cursor.
1075/// * `owner_events` - If 1, the `grab_window` will still get the pointer events. If 0, events are not
1076/// reported to the `grab_window`.
1077/// * `grab_window` - Specifies the window on which the pointer should be grabbed.
1078/// * `time` - The time argument allows you to avoid certain circumstances that come up if
1079/// applications take a long time to respond or if there are long network delays.
1080/// Consider a situation where you have two applications, both of which normally
1081/// grab the pointer when clicked on. If both applications specify the timestamp
1082/// from the event, the second application may wake up faster and successfully grab
1083/// the pointer before the first application. The first application then will get
1084/// an indication that the other application grabbed the pointer before its request
1085/// was processed.
1086///
1087/// The special value `XCB_CURRENT_TIME` will be replaced with the current server
1088/// time.
1089/// * `pointer_mode` -
1090/// * `keyboard_mode` -
1091///
1092/// # Errors
1093///
1094/// * `Value` - TODO: reasons?
1095/// * `Window` - The specified `window` does not exist.
1096///
1097/// # See
1098///
1099/// * `GrabKeyboard`: request
1100///
1101/// # Example
1102///
1103/// ```text
1104/// /*
1105///  * Grabs the pointer actively
1106///  *
1107///  */
1108/// void my_example(xcb_connection_t *conn, xcb_screen_t *screen, xcb_cursor_t cursor) {
1109///     xcb_grab_pointer_cookie_t cookie;
1110///     xcb_grab_pointer_reply_t *reply;
1111///
1112///     cookie = xcb_grab_pointer(
1113///         conn,
1114///         false,               /* get all pointer events specified by the following mask */
1115///         screen->root,        /* grab the root window */
1116///         XCB_NONE,            /* which events to let through */
1117///         XCB_GRAB_MODE_ASYNC, /* pointer events should continue as normal */
1118///         XCB_GRAB_MODE_ASYNC, /* keyboard mode */
1119///         XCB_NONE,            /* confine_to = in which window should the cursor stay */
1120///         cursor,              /* we change the cursor to whatever the user wanted */
1121///         XCB_CURRENT_TIME
1122///     );
1123///
1124///     if ((reply = xcb_grab_pointer_reply(conn, cookie, NULL))) {
1125///         if (reply->status == XCB_GRAB_STATUS_SUCCESS)
1126///             printf("successfully grabbed the pointer\\n");
1127///         free(reply);
1128///     }
1129/// }
1130/// ```
1131pub fn grab_pointer<Conn, A, B, C>(conn: &Conn, owner_events: bool, grab_window: Window, event_mask: EventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, time: C) -> Result<Cookie<'_, Conn, GrabPointerReply>, ConnectionError>
1132where
1133    Conn: RequestConnection + ?Sized,
1134    A: Into<Window>,
1135    B: Into<Cursor>,
1136    C: Into<Timestamp>,
1137{
1138    let confine_to: Window = confine_to.into();
1139    let cursor: Cursor = cursor.into();
1140    let time: Timestamp = time.into();
1141    let request0 = GrabPointerRequest {
1142        owner_events,
1143        grab_window,
1144        event_mask,
1145        pointer_mode,
1146        keyboard_mode,
1147        confine_to,
1148        cursor,
1149        time,
1150    };
1151    let (bytes, fds) = request0.serialize();
1152    let slices = [IoSlice::new(&bytes[0])];
1153    assert_eq!(slices.len(), bytes.len());
1154    conn.send_request_with_reply(&slices, fds)
1155}
1156
1157/// release the pointer.
1158///
1159/// Releases the pointer and any queued events if you actively grabbed the pointer
1160/// before using `xcb_grab_pointer`, `xcb_grab_button` or within a normal button
1161/// press.
1162///
1163/// EnterNotify and LeaveNotify events are generated.
1164///
1165/// # Fields
1166///
1167/// * `time` - Timestamp to avoid race conditions when running X over the network.
1168///
1169/// The pointer will not be released if `time` is earlier than the
1170/// last-pointer-grab time or later than the current X server time.
1171/// * `name_len` - Length (in bytes) of `name`.
1172/// * `name` - A pattern describing an X core font.
1173///
1174/// # See
1175///
1176/// * `GrabPointer`: request
1177/// * `GrabButton`: request
1178/// * `EnterNotify`: event
1179/// * `LeaveNotify`: event
1180pub fn ungrab_pointer<Conn, A>(conn: &Conn, time: A) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1181where
1182    Conn: RequestConnection + ?Sized,
1183    A: Into<Timestamp>,
1184{
1185    let time: Timestamp = time.into();
1186    let request0 = UngrabPointerRequest {
1187        time,
1188    };
1189    let (bytes, fds) = request0.serialize();
1190    let slices = [IoSlice::new(&bytes[0])];
1191    assert_eq!(slices.len(), bytes.len());
1192    conn.send_request_without_reply(&slices, fds)
1193}
1194
1195/// Grab pointer button(s).
1196///
1197/// This request establishes a passive grab. The pointer is actively grabbed as
1198/// described in GrabPointer, the last-pointer-grab time is set to the time at
1199/// which the button was pressed (as transmitted in the ButtonPress event), and the
1200/// ButtonPress event is reported if all of the following conditions are true:
1201///
1202/// The pointer is not grabbed and the specified button is logically pressed when
1203/// the specified modifier keys are logically down, and no other buttons or
1204/// modifier keys are logically down.
1205///
1206/// The grab-window contains the pointer.
1207///
1208/// The confine-to window (if any) is viewable.
1209///
1210/// A passive grab on the same button/key combination does not exist on any
1211/// ancestor of grab-window.
1212///
1213/// The interpretation of the remaining arguments is the same as for GrabPointer.
1214/// The active grab is terminated automatically when the logical state of the
1215/// pointer has all buttons released, independent of the logical state of modifier
1216/// keys. Note that the logical state of a device (as seen by means of the
1217/// protocol) may lag the physical state if device event processing is frozen. This
1218/// request overrides all previous passive grabs by the same client on the same
1219/// button/key combinations on the same window. A modifier of AnyModifier is
1220/// equivalent to issuing the request for all possible modifier combinations
1221/// (including the combination of no modifiers). It is not required that all
1222/// specified modifiers have currently assigned keycodes. A button of AnyButton is
1223/// equivalent to issuing the request for all possible buttons. Otherwise, it is
1224/// not required that the button specified currently be assigned to a physical
1225/// button.
1226///
1227/// An Access error is generated if some other client has already issued a
1228/// GrabButton request with the same button/key combination on the same window.
1229/// When using AnyModifier or AnyButton, the request fails completely (no grabs are
1230/// established), and an Access error is generated if there is a conflicting grab
1231/// for any combination. The request has no effect on an active grab.
1232///
1233/// # Fields
1234///
1235/// * `owner_events` - If 1, the `grab_window` will still get the pointer events. If 0, events are not
1236/// reported to the `grab_window`.
1237/// * `grab_window` - Specifies the window on which the pointer should be grabbed.
1238/// * `event_mask` - Specifies which pointer events are reported to the client.
1239///
1240/// TODO: which values?
1241/// * `confine_to` - Specifies the window to confine the pointer in (the user will not be able to
1242/// move the pointer out of that window).
1243///
1244/// The special value `XCB_NONE` means don't confine the pointer.
1245/// * `cursor` - Specifies the cursor that should be displayed or `XCB_NONE` to not change the
1246/// cursor.
1247/// * `modifiers` - The modifiers to grab.
1248///
1249/// Using the special value `XCB_MOD_MASK_ANY` means grab the pointer with all
1250/// possible modifier combinations.
1251/// * `pointer_mode` -
1252/// * `keyboard_mode` -
1253/// * `button` -
1254///
1255/// # Errors
1256///
1257/// * `Access` - Another client has already issued a GrabButton with the same button/key
1258/// combination on the same window.
1259/// * `Value` - TODO: reasons?
1260/// * `Cursor` - The specified `cursor` does not exist.
1261/// * `Window` - The specified `window` does not exist.
1262pub fn grab_button<Conn, A, B>(conn: &Conn, owner_events: bool, grab_window: Window, event_mask: EventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, button: ButtonIndex, modifiers: ModMask) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1263where
1264    Conn: RequestConnection + ?Sized,
1265    A: Into<Window>,
1266    B: Into<Cursor>,
1267{
1268    let confine_to: Window = confine_to.into();
1269    let cursor: Cursor = cursor.into();
1270    let request0 = GrabButtonRequest {
1271        owner_events,
1272        grab_window,
1273        event_mask,
1274        pointer_mode,
1275        keyboard_mode,
1276        confine_to,
1277        cursor,
1278        button,
1279        modifiers,
1280    };
1281    let (bytes, fds) = request0.serialize();
1282    let slices = [IoSlice::new(&bytes[0])];
1283    assert_eq!(slices.len(), bytes.len());
1284    conn.send_request_without_reply(&slices, fds)
1285}
1286
1287pub fn ungrab_button<Conn>(conn: &Conn, button: ButtonIndex, grab_window: Window, modifiers: ModMask) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1288where
1289    Conn: RequestConnection + ?Sized,
1290{
1291    let request0 = UngrabButtonRequest {
1292        button,
1293        grab_window,
1294        modifiers,
1295    };
1296    let (bytes, fds) = request0.serialize();
1297    let slices = [IoSlice::new(&bytes[0])];
1298    assert_eq!(slices.len(), bytes.len());
1299    conn.send_request_without_reply(&slices, fds)
1300}
1301
1302pub fn change_active_pointer_grab<Conn, A, B>(conn: &Conn, cursor: A, time: B, event_mask: EventMask) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1303where
1304    Conn: RequestConnection + ?Sized,
1305    A: Into<Cursor>,
1306    B: Into<Timestamp>,
1307{
1308    let cursor: Cursor = cursor.into();
1309    let time: Timestamp = time.into();
1310    let request0 = ChangeActivePointerGrabRequest {
1311        cursor,
1312        time,
1313        event_mask,
1314    };
1315    let (bytes, fds) = request0.serialize();
1316    let slices = [IoSlice::new(&bytes[0])];
1317    assert_eq!(slices.len(), bytes.len());
1318    conn.send_request_without_reply(&slices, fds)
1319}
1320
1321/// Grab the keyboard.
1322///
1323/// Actively grabs control of the keyboard and generates FocusIn and FocusOut
1324/// events. Further key events are reported only to the grabbing client.
1325///
1326/// Any active keyboard grab by this client is overridden. If the keyboard is
1327/// actively grabbed by some other client, `AlreadyGrabbed` is returned. If
1328/// `grab_window` is not viewable, `GrabNotViewable` is returned. If the keyboard
1329/// is frozen by an active grab of another client, `GrabFrozen` is returned. If the
1330/// specified `time` is earlier than the last-keyboard-grab time or later than the
1331/// current X server time, `GrabInvalidTime` is returned. Otherwise, the
1332/// last-keyboard-grab time is set to the specified time.
1333///
1334/// # Fields
1335///
1336/// * `owner_events` - If 1, the `grab_window` will still get the pointer events. If 0, events are not
1337/// reported to the `grab_window`.
1338/// * `grab_window` - Specifies the window on which the pointer should be grabbed.
1339/// * `time` - Timestamp to avoid race conditions when running X over the network.
1340///
1341/// The special value `XCB_CURRENT_TIME` will be replaced with the current server
1342/// time.
1343/// * `pointer_mode` -
1344/// * `keyboard_mode` -
1345///
1346/// # Errors
1347///
1348/// * `Value` - TODO: reasons?
1349/// * `Window` - The specified `window` does not exist.
1350///
1351/// # See
1352///
1353/// * `GrabPointer`: request
1354///
1355/// # Example
1356///
1357/// ```text
1358/// /*
1359///  * Grabs the keyboard actively
1360///  *
1361///  */
1362/// void my_example(xcb_connection_t *conn, xcb_screen_t *screen) {
1363///     xcb_grab_keyboard_cookie_t cookie;
1364///     xcb_grab_keyboard_reply_t *reply;
1365///
1366///     cookie = xcb_grab_keyboard(
1367///         conn,
1368///         true,                /* report events */
1369///         screen->root,        /* grab the root window */
1370///         XCB_CURRENT_TIME,
1371///         XCB_GRAB_MODE_ASYNC, /* process events as normal, do not require sync */
1372///         XCB_GRAB_MODE_ASYNC
1373///     );
1374///
1375///     if ((reply = xcb_grab_keyboard_reply(conn, cookie, NULL))) {
1376///         if (reply->status == XCB_GRAB_STATUS_SUCCESS)
1377///             printf("successfully grabbed the keyboard\\n");
1378///
1379///         free(reply);
1380///     }
1381/// }
1382/// ```
1383pub fn grab_keyboard<Conn, A>(conn: &Conn, owner_events: bool, grab_window: Window, time: A, pointer_mode: GrabMode, keyboard_mode: GrabMode) -> Result<Cookie<'_, Conn, GrabKeyboardReply>, ConnectionError>
1384where
1385    Conn: RequestConnection + ?Sized,
1386    A: Into<Timestamp>,
1387{
1388    let time: Timestamp = time.into();
1389    let request0 = GrabKeyboardRequest {
1390        owner_events,
1391        grab_window,
1392        time,
1393        pointer_mode,
1394        keyboard_mode,
1395    };
1396    let (bytes, fds) = request0.serialize();
1397    let slices = [IoSlice::new(&bytes[0])];
1398    assert_eq!(slices.len(), bytes.len());
1399    conn.send_request_with_reply(&slices, fds)
1400}
1401
1402pub fn ungrab_keyboard<Conn, A>(conn: &Conn, time: A) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1403where
1404    Conn: RequestConnection + ?Sized,
1405    A: Into<Timestamp>,
1406{
1407    let time: Timestamp = time.into();
1408    let request0 = UngrabKeyboardRequest {
1409        time,
1410    };
1411    let (bytes, fds) = request0.serialize();
1412    let slices = [IoSlice::new(&bytes[0])];
1413    assert_eq!(slices.len(), bytes.len());
1414    conn.send_request_without_reply(&slices, fds)
1415}
1416
1417/// Grab keyboard key(s).
1418///
1419/// Establishes a passive grab on the keyboard. In the future, the keyboard is
1420/// actively grabbed (as for `GrabKeyboard`), the last-keyboard-grab time is set to
1421/// the time at which the key was pressed (as transmitted in the KeyPress event),
1422/// and the KeyPress event is reported if all of the following conditions are true:
1423///
1424/// The keyboard is not grabbed and the specified key (which can itself be a
1425/// modifier key) is logically pressed when the specified modifier keys are
1426/// logically down, and no other modifier keys are logically down.
1427///
1428/// Either the grab_window is an ancestor of (or is) the focus window, or the
1429/// grab_window is a descendant of the focus window and contains the pointer.
1430///
1431/// A passive grab on the same key combination does not exist on any ancestor of
1432/// grab_window.
1433///
1434/// The interpretation of the remaining arguments is as for XGrabKeyboard.  The active grab is terminated
1435/// automatically when the logical state of the keyboard has the specified key released (independent of the
1436/// logical state of the modifier keys), at which point a KeyRelease event is reported to the grabbing window.
1437///
1438/// Note that the logical state of a device (as seen by client applications) may lag the physical state if
1439/// device event processing is frozen.
1440///
1441/// A modifiers argument of AnyModifier is equivalent to issuing the request for all possible modifier combinations (including the combination of no modifiers).  It is not required that all modifiers specified
1442/// have currently assigned KeyCodes.  A keycode argument of AnyKey is equivalent to issuing the request for
1443/// all possible KeyCodes.  Otherwise, the specified keycode must be in the range specified by min_keycode
1444/// and max_keycode in the connection setup, or a BadValue error results.
1445///
1446/// If some other client has issued a XGrabKey with the same key combination on the same window, a BadAccess
1447/// error results.  When using AnyModifier or AnyKey, the request fails completely, and a BadAccess error
1448/// results (no grabs are established) if there is a conflicting grab for any combination.
1449///
1450/// # Fields
1451///
1452/// * `owner_events` - If 1, the `grab_window` will still get the key events. If 0, events are not
1453/// reported to the `grab_window`.
1454/// * `grab_window` - Specifies the window on which the key should be grabbed.
1455/// * `key` - The keycode of the key to grab.
1456///
1457/// The special value `XCB_GRAB_ANY` means grab any key.
1458/// * `modifiers` - The modifiers to grab.
1459///
1460/// Using the special value `XCB_MOD_MASK_ANY` means grab the key with all
1461/// possible modifier combinations.
1462/// * `pointer_mode` -
1463/// * `keyboard_mode` -
1464///
1465/// # Errors
1466///
1467/// * `Access` - Another client has already issued a GrabKey with the same button/key
1468/// combination on the same window.
1469/// * `Value` - The key is not `XCB_GRAB_ANY` and not in the range specified by `min_keycode`
1470/// and `max_keycode` in the connection setup.
1471/// * `Window` - The specified `window` does not exist.
1472///
1473/// # See
1474///
1475/// * `GrabKeyboard`: request
1476pub fn grab_key<Conn, A>(conn: &Conn, owner_events: bool, grab_window: Window, modifiers: ModMask, key: A, pointer_mode: GrabMode, keyboard_mode: GrabMode) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1477where
1478    Conn: RequestConnection + ?Sized,
1479    A: Into<Keycode>,
1480{
1481    let key: Keycode = key.into();
1482    let request0 = GrabKeyRequest {
1483        owner_events,
1484        grab_window,
1485        modifiers,
1486        key,
1487        pointer_mode,
1488        keyboard_mode,
1489    };
1490    let (bytes, fds) = request0.serialize();
1491    let slices = [IoSlice::new(&bytes[0])];
1492    assert_eq!(slices.len(), bytes.len());
1493    conn.send_request_without_reply(&slices, fds)
1494}
1495
1496/// release a key combination.
1497///
1498/// Releases the key combination on `grab_window` if you grabbed it using
1499/// `xcb_grab_key` before.
1500///
1501/// # Fields
1502///
1503/// * `key` - The keycode of the specified key combination.
1504///
1505/// Using the special value `XCB_GRAB_ANY` means releasing all possible key codes.
1506/// * `grab_window` - The window on which the grabbed key combination will be released.
1507/// * `modifiers` - The modifiers of the specified key combination.
1508///
1509/// Using the special value `XCB_MOD_MASK_ANY` means releasing the key combination
1510/// with every possible modifier combination.
1511///
1512/// # Errors
1513///
1514/// * `Window` - The specified `grab_window` does not exist.
1515/// * `Value` - TODO: reasons?
1516///
1517/// # See
1518///
1519/// * `GrabKey`: request
1520/// * `xev`: program
1521pub fn ungrab_key<Conn, A>(conn: &Conn, key: A, grab_window: Window, modifiers: ModMask) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1522where
1523    Conn: RequestConnection + ?Sized,
1524    A: Into<Keycode>,
1525{
1526    let key: Keycode = key.into();
1527    let request0 = UngrabKeyRequest {
1528        key,
1529        grab_window,
1530        modifiers,
1531    };
1532    let (bytes, fds) = request0.serialize();
1533    let slices = [IoSlice::new(&bytes[0])];
1534    assert_eq!(slices.len(), bytes.len());
1535    conn.send_request_without_reply(&slices, fds)
1536}
1537
1538/// release queued events.
1539///
1540/// Releases queued events if the client has caused a device (pointer/keyboard) to
1541/// freeze due to grabbing it actively. This request has no effect if `time` is
1542/// earlier than the last-grab time of the most recent active grab for this client
1543/// or if `time` is later than the current X server time.
1544///
1545/// # Fields
1546///
1547/// * `mode` -
1548/// * `time` - Timestamp to avoid race conditions when running X over the network.
1549///
1550/// The special value `XCB_CURRENT_TIME` will be replaced with the current server
1551/// time.
1552///
1553/// # Errors
1554///
1555/// * `Value` - You specified an invalid `mode`.
1556pub fn allow_events<Conn, A>(conn: &Conn, mode: Allow, time: A) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1557where
1558    Conn: RequestConnection + ?Sized,
1559    A: Into<Timestamp>,
1560{
1561    let time: Timestamp = time.into();
1562    let request0 = AllowEventsRequest {
1563        mode,
1564        time,
1565    };
1566    let (bytes, fds) = request0.serialize();
1567    let slices = [IoSlice::new(&bytes[0])];
1568    assert_eq!(slices.len(), bytes.len());
1569    conn.send_request_without_reply(&slices, fds)
1570}
1571
1572pub fn grab_server<Conn>(conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1573where
1574    Conn: RequestConnection + ?Sized,
1575{
1576    let request0 = GrabServerRequest;
1577    let (bytes, fds) = request0.serialize();
1578    let slices = [IoSlice::new(&bytes[0])];
1579    assert_eq!(slices.len(), bytes.len());
1580    conn.send_request_without_reply(&slices, fds)
1581}
1582
1583pub fn ungrab_server<Conn>(conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1584where
1585    Conn: RequestConnection + ?Sized,
1586{
1587    let request0 = UngrabServerRequest;
1588    let (bytes, fds) = request0.serialize();
1589    let slices = [IoSlice::new(&bytes[0])];
1590    assert_eq!(slices.len(), bytes.len());
1591    conn.send_request_without_reply(&slices, fds)
1592}
1593
1594/// get pointer coordinates.
1595///
1596/// Gets the root window the pointer is logically on and the pointer coordinates
1597/// relative to the root window's origin.
1598///
1599/// # Fields
1600///
1601/// * `window` - A window to check if the pointer is on the same screen as `window` (see the
1602/// `same_screen` field in the reply).
1603///
1604/// # Errors
1605///
1606/// * `Window` - The specified `window` does not exist.
1607pub fn query_pointer<Conn>(conn: &Conn, window: Window) -> Result<Cookie<'_, Conn, QueryPointerReply>, ConnectionError>
1608where
1609    Conn: RequestConnection + ?Sized,
1610{
1611    let request0 = QueryPointerRequest {
1612        window,
1613    };
1614    let (bytes, fds) = request0.serialize();
1615    let slices = [IoSlice::new(&bytes[0])];
1616    assert_eq!(slices.len(), bytes.len());
1617    conn.send_request_with_reply(&slices, fds)
1618}
1619
1620pub fn get_motion_events<Conn, A, B>(conn: &Conn, window: Window, start: A, stop: B) -> Result<Cookie<'_, Conn, GetMotionEventsReply>, ConnectionError>
1621where
1622    Conn: RequestConnection + ?Sized,
1623    A: Into<Timestamp>,
1624    B: Into<Timestamp>,
1625{
1626    let start: Timestamp = start.into();
1627    let stop: Timestamp = stop.into();
1628    let request0 = GetMotionEventsRequest {
1629        window,
1630        start,
1631        stop,
1632    };
1633    let (bytes, fds) = request0.serialize();
1634    let slices = [IoSlice::new(&bytes[0])];
1635    assert_eq!(slices.len(), bytes.len());
1636    conn.send_request_with_reply(&slices, fds)
1637}
1638
1639pub fn translate_coordinates<Conn>(conn: &Conn, src_window: Window, dst_window: Window, src_x: i16, src_y: i16) -> Result<Cookie<'_, Conn, TranslateCoordinatesReply>, ConnectionError>
1640where
1641    Conn: RequestConnection + ?Sized,
1642{
1643    let request0 = TranslateCoordinatesRequest {
1644        src_window,
1645        dst_window,
1646        src_x,
1647        src_y,
1648    };
1649    let (bytes, fds) = request0.serialize();
1650    let slices = [IoSlice::new(&bytes[0])];
1651    assert_eq!(slices.len(), bytes.len());
1652    conn.send_request_with_reply(&slices, fds)
1653}
1654
1655/// move mouse pointer.
1656///
1657/// Moves the mouse pointer to the specified position.
1658///
1659/// If `src_window` is not `XCB_NONE` (TODO), the move will only take place if the
1660/// pointer is inside `src_window` and within the rectangle specified by (`src_x`,
1661/// `src_y`, `src_width`, `src_height`). The rectangle coordinates are relative to
1662/// `src_window`.
1663///
1664/// If `dst_window` is not `XCB_NONE` (TODO), the pointer will be moved to the
1665/// offsets (`dst_x`, `dst_y`) relative to `dst_window`. If `dst_window` is
1666/// `XCB_NONE` (TODO), the pointer will be moved by the offsets (`dst_x`, `dst_y`)
1667/// relative to the current position of the pointer.
1668///
1669/// # Fields
1670///
1671/// * `src_window` - If `src_window` is not `XCB_NONE` (TODO), the move will only take place if the
1672/// pointer is inside `src_window` and within the rectangle specified by (`src_x`,
1673/// `src_y`, `src_width`, `src_height`). The rectangle coordinates are relative to
1674/// `src_window`.
1675/// * `dst_window` - If `dst_window` is not `XCB_NONE` (TODO), the pointer will be moved to the
1676/// offsets (`dst_x`, `dst_y`) relative to `dst_window`. If `dst_window` is
1677/// `XCB_NONE` (TODO), the pointer will be moved by the offsets (`dst_x`, `dst_y`)
1678/// relative to the current position of the pointer.
1679///
1680/// # Errors
1681///
1682/// * `Window` - TODO: reasons?
1683///
1684/// # See
1685///
1686/// * `SetInputFocus`: request
1687pub fn warp_pointer<Conn, A, B>(conn: &Conn, src_window: A, dst_window: B, src_x: i16, src_y: i16, src_width: u16, src_height: u16, dst_x: i16, dst_y: i16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1688where
1689    Conn: RequestConnection + ?Sized,
1690    A: Into<Window>,
1691    B: Into<Window>,
1692{
1693    let src_window: Window = src_window.into();
1694    let dst_window: Window = dst_window.into();
1695    let request0 = WarpPointerRequest {
1696        src_window,
1697        dst_window,
1698        src_x,
1699        src_y,
1700        src_width,
1701        src_height,
1702        dst_x,
1703        dst_y,
1704    };
1705    let (bytes, fds) = request0.serialize();
1706    let slices = [IoSlice::new(&bytes[0])];
1707    assert_eq!(slices.len(), bytes.len());
1708    conn.send_request_without_reply(&slices, fds)
1709}
1710
1711/// Sets input focus.
1712///
1713/// Changes the input focus and the last-focus-change time. If the specified `time`
1714/// is earlier than the current last-focus-change time, the request is ignored (to
1715/// avoid race conditions when running X over the network).
1716///
1717/// A FocusIn and FocusOut event is generated when focus is changed.
1718///
1719/// # Fields
1720///
1721/// * `focus` - The window to focus. All keyboard events will be reported to this window. The
1722/// window must be viewable (TODO), or a `xcb_match_error_t` occurs (TODO).
1723///
1724/// If `focus` is `XCB_NONE` (TODO), all keyboard events are
1725/// discarded until a new focus window is set.
1726///
1727/// If `focus` is `XCB_POINTER_ROOT` (TODO), focus is on the root window of the
1728/// screen on which the pointer is on currently.
1729/// * `time` - Timestamp to avoid race conditions when running X over the network.
1730///
1731/// The special value `XCB_CURRENT_TIME` will be replaced with the current server
1732/// time.
1733/// * `revert_to` - Specifies what happens when the `focus` window becomes unviewable (if `focus`
1734/// is neither `XCB_NONE` nor `XCB_POINTER_ROOT`).
1735///
1736/// # Errors
1737///
1738/// * `Window` - The specified `focus` window does not exist.
1739/// * `Match` - The specified `focus` window is not viewable.
1740/// * `Value` - TODO: Reasons?
1741///
1742/// # See
1743///
1744/// * `FocusIn`: event
1745/// * `FocusOut`: event
1746pub fn set_input_focus<Conn, A, B>(conn: &Conn, revert_to: InputFocus, focus: A, time: B) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1747where
1748    Conn: RequestConnection + ?Sized,
1749    A: Into<Window>,
1750    B: Into<Timestamp>,
1751{
1752    let focus: Window = focus.into();
1753    let time: Timestamp = time.into();
1754    let request0 = SetInputFocusRequest {
1755        revert_to,
1756        focus,
1757        time,
1758    };
1759    let (bytes, fds) = request0.serialize();
1760    let slices = [IoSlice::new(&bytes[0])];
1761    assert_eq!(slices.len(), bytes.len());
1762    conn.send_request_without_reply(&slices, fds)
1763}
1764
1765pub fn get_input_focus<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetInputFocusReply>, ConnectionError>
1766where
1767    Conn: RequestConnection + ?Sized,
1768{
1769    let request0 = GetInputFocusRequest;
1770    let (bytes, fds) = request0.serialize();
1771    let slices = [IoSlice::new(&bytes[0])];
1772    assert_eq!(slices.len(), bytes.len());
1773    conn.send_request_with_reply(&slices, fds)
1774}
1775
1776pub fn query_keymap<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryKeymapReply>, ConnectionError>
1777where
1778    Conn: RequestConnection + ?Sized,
1779{
1780    let request0 = QueryKeymapRequest;
1781    let (bytes, fds) = request0.serialize();
1782    let slices = [IoSlice::new(&bytes[0])];
1783    assert_eq!(slices.len(), bytes.len());
1784    conn.send_request_with_reply(&slices, fds)
1785}
1786
1787/// opens a font.
1788///
1789/// Opens any X core font matching the given `name` (for example "-misc-fixed-*").
1790///
1791/// Note that X core fonts are deprecated (but still supported) in favor of
1792/// client-side rendering using Xft.
1793///
1794/// # Fields
1795///
1796/// * `fid` - The ID with which you will refer to the font, created by `xcb_generate_id`.
1797/// * `name_len` - Length (in bytes) of `name`.
1798/// * `name` - A pattern describing an X core font.
1799///
1800/// # Errors
1801///
1802/// * `Name` - No font matches the given `name`.
1803///
1804/// # See
1805///
1806/// * `xcb_generate_id`: function
1807pub fn open_font<'c, 'input, Conn>(conn: &'c Conn, fid: Font, name: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
1808where
1809    Conn: RequestConnection + ?Sized,
1810{
1811    let request0 = OpenFontRequest {
1812        fid,
1813        name: Cow::Borrowed(name),
1814    };
1815    let (bytes, fds) = request0.serialize();
1816    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
1817    assert_eq!(slices.len(), bytes.len());
1818    conn.send_request_without_reply(&slices, fds)
1819}
1820
1821pub fn close_font<Conn>(conn: &Conn, font: Font) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1822where
1823    Conn: RequestConnection + ?Sized,
1824{
1825    let request0 = CloseFontRequest {
1826        font,
1827    };
1828    let (bytes, fds) = request0.serialize();
1829    let slices = [IoSlice::new(&bytes[0])];
1830    assert_eq!(slices.len(), bytes.len());
1831    conn.send_request_without_reply(&slices, fds)
1832}
1833
1834/// query font metrics.
1835///
1836/// Queries information associated with the font.
1837///
1838/// # Fields
1839///
1840/// * `font` - The fontable (Font or Graphics Context) to query.
1841pub fn query_font<Conn>(conn: &Conn, font: Fontable) -> Result<Cookie<'_, Conn, QueryFontReply>, ConnectionError>
1842where
1843    Conn: RequestConnection + ?Sized,
1844{
1845    let request0 = QueryFontRequest {
1846        font,
1847    };
1848    let (bytes, fds) = request0.serialize();
1849    let slices = [IoSlice::new(&bytes[0])];
1850    assert_eq!(slices.len(), bytes.len());
1851    conn.send_request_with_reply(&slices, fds)
1852}
1853
1854/// get text extents.
1855///
1856/// Query text extents from the X11 server. This request returns the bounding box
1857/// of the specified 16-bit character string in the specified `font` or the font
1858/// contained in the specified graphics context.
1859///
1860/// `font_ascent` is set to the maximum of the ascent metrics of all characters in
1861/// the string. `font_descent` is set to the maximum of the descent metrics.
1862/// `overall_width` is set to the sum of the character-width metrics of all
1863/// characters in the string. For each character in the string, let W be the sum of
1864/// the character-width metrics of all characters preceding it in the string. Let L
1865/// be the left-side-bearing metric of the character plus W. Let R be the
1866/// right-side-bearing metric of the character plus W. The lbearing member is set
1867/// to the minimum L of all characters in the string. The rbearing member is set to
1868/// the maximum R.
1869///
1870/// For fonts defined with linear indexing rather than 2-byte matrix indexing, each
1871/// `xcb_char2b_t` structure is interpreted as a 16-bit number with byte1 as the
1872/// most significant byte. If the font has no defined default character, undefined
1873/// characters in the string are taken to have all zero metrics.
1874///
1875/// Characters with all zero metrics are ignored. If the font has no defined
1876/// default_char, the undefined characters in the string are also ignored.
1877///
1878/// # Fields
1879///
1880/// * `font` - The `font` to calculate text extents in. You can also pass a graphics context.
1881/// * `string_len` - The number of characters in `string`.
1882/// * `string` - The text to get text extents for.
1883///
1884/// # Errors
1885///
1886/// * `GContext` - The specified graphics context does not exist.
1887/// * `Font` - The specified `font` does not exist.
1888pub fn query_text_extents<'c, 'input, Conn>(conn: &'c Conn, font: Fontable, string: &'input [Char2b]) -> Result<Cookie<'c, Conn, QueryTextExtentsReply>, ConnectionError>
1889where
1890    Conn: RequestConnection + ?Sized,
1891{
1892    let request0 = QueryTextExtentsRequest {
1893        font,
1894        string: Cow::Borrowed(string),
1895    };
1896    let (bytes, fds) = request0.serialize();
1897    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
1898    assert_eq!(slices.len(), bytes.len());
1899    conn.send_request_with_reply(&slices, fds)
1900}
1901
1902/// get matching font names.
1903///
1904/// Gets a list of available font names which match the given `pattern`.
1905///
1906/// # Fields
1907///
1908/// * `pattern_len` - The length (in bytes) of `pattern`.
1909/// * `pattern` - A font pattern, for example "-misc-fixed-*".
1910///
1911/// The asterisk (*) is a wildcard for any number of characters. The question mark
1912/// (?) is a wildcard for a single character. Use of uppercase or lowercase does
1913/// not matter.
1914/// * `max_names` - The maximum number of fonts to be returned.
1915pub fn list_fonts<'c, 'input, Conn>(conn: &'c Conn, max_names: u16, pattern: &'input [u8]) -> Result<Cookie<'c, Conn, ListFontsReply>, ConnectionError>
1916where
1917    Conn: RequestConnection + ?Sized,
1918{
1919    let request0 = ListFontsRequest {
1920        max_names,
1921        pattern: Cow::Borrowed(pattern),
1922    };
1923    let (bytes, fds) = request0.serialize();
1924    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
1925    assert_eq!(slices.len(), bytes.len());
1926    conn.send_request_with_reply(&slices, fds)
1927}
1928
1929/// get matching font names and information.
1930///
1931/// Gets a list of available font names which match the given `pattern`.
1932///
1933/// # Fields
1934///
1935/// * `pattern_len` - The length (in bytes) of `pattern`.
1936/// * `pattern` - A font pattern, for example "-misc-fixed-*".
1937///
1938/// The asterisk (*) is a wildcard for any number of characters. The question mark
1939/// (?) is a wildcard for a single character. Use of uppercase or lowercase does
1940/// not matter.
1941/// * `max_names` - The maximum number of fonts to be returned.
1942pub fn list_fonts_with_info<'c, 'input, Conn>(conn: &'c Conn, max_names: u16, pattern: &'input [u8]) -> Result<ListFontsWithInfoCookie<'c, Conn>, ConnectionError>
1943where
1944    Conn: RequestConnection + ?Sized,
1945{
1946    let request0 = ListFontsWithInfoRequest {
1947        max_names,
1948        pattern: Cow::Borrowed(pattern),
1949    };
1950    let (bytes, fds) = request0.serialize();
1951    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
1952    assert_eq!(slices.len(), bytes.len());
1953    Ok(ListFontsWithInfoCookie::new(conn.send_request_with_reply(&slices, fds)?))
1954}
1955
1956pub fn set_font_path<'c, 'input, Conn>(conn: &'c Conn, font: &'input [Str]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
1957where
1958    Conn: RequestConnection + ?Sized,
1959{
1960    let request0 = SetFontPathRequest {
1961        font: Cow::Borrowed(font),
1962    };
1963    let (bytes, fds) = request0.serialize();
1964    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
1965    assert_eq!(slices.len(), bytes.len());
1966    conn.send_request_without_reply(&slices, fds)
1967}
1968
1969pub fn get_font_path<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetFontPathReply>, ConnectionError>
1970where
1971    Conn: RequestConnection + ?Sized,
1972{
1973    let request0 = GetFontPathRequest;
1974    let (bytes, fds) = request0.serialize();
1975    let slices = [IoSlice::new(&bytes[0])];
1976    assert_eq!(slices.len(), bytes.len());
1977    conn.send_request_with_reply(&slices, fds)
1978}
1979
1980/// Creates a pixmap.
1981///
1982/// Creates a pixmap. The pixmap can only be used on the same screen as `drawable`
1983/// is on and only with drawables of the same `depth`.
1984///
1985/// # Fields
1986///
1987/// * `depth` - TODO
1988/// * `pid` - The ID with which you will refer to the new pixmap, created by
1989/// `xcb_generate_id`.
1990/// * `drawable` - Drawable to get the screen from.
1991/// * `width` - The width of the new pixmap.
1992/// * `height` - The height of the new pixmap.
1993///
1994/// # Errors
1995///
1996/// * `Value` - TODO: reasons?
1997/// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
1998/// * `Alloc` - The X server could not allocate the requested resources (no memory?).
1999///
2000/// # See
2001///
2002/// * `xcb_generate_id`: function
2003pub fn create_pixmap<Conn>(conn: &Conn, depth: u8, pid: Pixmap, drawable: Drawable, width: u16, height: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2004where
2005    Conn: RequestConnection + ?Sized,
2006{
2007    let request0 = CreatePixmapRequest {
2008        depth,
2009        pid,
2010        drawable,
2011        width,
2012        height,
2013    };
2014    let (bytes, fds) = request0.serialize();
2015    let slices = [IoSlice::new(&bytes[0])];
2016    assert_eq!(slices.len(), bytes.len());
2017    conn.send_request_without_reply(&slices, fds)
2018}
2019
2020/// Destroys a pixmap.
2021///
2022/// Deletes the association between the pixmap ID and the pixmap. The pixmap
2023/// storage will be freed when there are no more references to it.
2024///
2025/// # Fields
2026///
2027/// * `pixmap` - The pixmap to destroy.
2028///
2029/// # Errors
2030///
2031/// * `Pixmap` - The specified pixmap does not exist.
2032pub fn free_pixmap<Conn>(conn: &Conn, pixmap: Pixmap) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2033where
2034    Conn: RequestConnection + ?Sized,
2035{
2036    let request0 = FreePixmapRequest {
2037        pixmap,
2038    };
2039    let (bytes, fds) = request0.serialize();
2040    let slices = [IoSlice::new(&bytes[0])];
2041    assert_eq!(slices.len(), bytes.len());
2042    conn.send_request_without_reply(&slices, fds)
2043}
2044
2045/// Creates a graphics context.
2046///
2047/// Creates a graphics context. The graphics context can be used with any drawable
2048/// that has the same root and depth as the specified drawable.
2049///
2050/// # Fields
2051///
2052/// * `cid` - The ID with which you will refer to the graphics context, created by
2053/// `xcb_generate_id`.
2054/// * `drawable` - Drawable to get the root/depth from.
2055///
2056/// # Errors
2057///
2058/// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
2059/// * `Match` - TODO: reasons?
2060/// * `Font` - TODO: reasons?
2061/// * `Pixmap` - TODO: reasons?
2062/// * `Value` - TODO: reasons?
2063/// * `Alloc` - The X server could not allocate the requested resources (no memory?).
2064///
2065/// # See
2066///
2067/// * `xcb_generate_id`: function
2068pub fn create_gc<'c, 'input, Conn>(conn: &'c Conn, cid: Gcontext, drawable: Drawable, value_list: &'input CreateGCAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2069where
2070    Conn: RequestConnection + ?Sized,
2071{
2072    let request0 = CreateGCRequest {
2073        cid,
2074        drawable,
2075        value_list: Cow::Borrowed(value_list),
2076    };
2077    let (bytes, fds) = request0.serialize();
2078    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2079    assert_eq!(slices.len(), bytes.len());
2080    conn.send_request_without_reply(&slices, fds)
2081}
2082
2083/// change graphics context components.
2084///
2085/// Changes the components specified by `value_mask` for the specified graphics context.
2086///
2087/// # Fields
2088///
2089/// * `gc` - The graphics context to change.
2090/// * `value_mask` -
2091/// * `value_list` - Values for each of the components specified in the bitmask `value_mask`. The
2092/// order has to correspond to the order of possible `value_mask` bits. See the
2093/// example.
2094///
2095/// # Errors
2096///
2097/// * `Font` - TODO: reasons?
2098/// * `GContext` - TODO: reasons?
2099/// * `Match` - TODO: reasons?
2100/// * `Pixmap` - TODO: reasons?
2101/// * `Value` - TODO: reasons?
2102/// * `Alloc` - The X server could not allocate the requested resources (no memory?).
2103///
2104/// # Example
2105///
2106/// ```text
2107/// /*
2108///  * Changes the foreground color component of the specified graphics context.
2109///  *
2110///  */
2111/// void my_example(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t fg, uint32_t bg) {
2112///     /* C99 allows us to use a compact way of changing a single component: */
2113///     xcb_change_gc(conn, gc, XCB_GC_FOREGROUND, (uint32_t[]){ fg });
2114///
2115///     /* The more explicit way. Beware that the order of values is important! */
2116///     uint32_t mask = 0;
2117///     mask |= XCB_GC_FOREGROUND;
2118///     mask |= XCB_GC_BACKGROUND;
2119///
2120///     uint32_t values[] = {
2121///         fg,
2122///         bg
2123///     };
2124///     xcb_change_gc(conn, gc, mask, values);
2125///     xcb_flush(conn);
2126/// }
2127/// ```
2128pub fn change_gc<'c, 'input, Conn>(conn: &'c Conn, gc: Gcontext, value_list: &'input ChangeGCAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2129where
2130    Conn: RequestConnection + ?Sized,
2131{
2132    let request0 = ChangeGCRequest {
2133        gc,
2134        value_list: Cow::Borrowed(value_list),
2135    };
2136    let (bytes, fds) = request0.serialize();
2137    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2138    assert_eq!(slices.len(), bytes.len());
2139    conn.send_request_without_reply(&slices, fds)
2140}
2141
2142pub fn copy_gc<Conn>(conn: &Conn, src_gc: Gcontext, dst_gc: Gcontext, value_mask: GC) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2143where
2144    Conn: RequestConnection + ?Sized,
2145{
2146    let request0 = CopyGCRequest {
2147        src_gc,
2148        dst_gc,
2149        value_mask,
2150    };
2151    let (bytes, fds) = request0.serialize();
2152    let slices = [IoSlice::new(&bytes[0])];
2153    assert_eq!(slices.len(), bytes.len());
2154    conn.send_request_without_reply(&slices, fds)
2155}
2156
2157pub fn set_dashes<'c, 'input, Conn>(conn: &'c Conn, gc: Gcontext, dash_offset: u16, dashes: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2158where
2159    Conn: RequestConnection + ?Sized,
2160{
2161    let request0 = SetDashesRequest {
2162        gc,
2163        dash_offset,
2164        dashes: Cow::Borrowed(dashes),
2165    };
2166    let (bytes, fds) = request0.serialize();
2167    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2168    assert_eq!(slices.len(), bytes.len());
2169    conn.send_request_without_reply(&slices, fds)
2170}
2171
2172pub fn set_clip_rectangles<'c, 'input, Conn>(conn: &'c Conn, ordering: ClipOrdering, gc: Gcontext, clip_x_origin: i16, clip_y_origin: i16, rectangles: &'input [Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2173where
2174    Conn: RequestConnection + ?Sized,
2175{
2176    let request0 = SetClipRectanglesRequest {
2177        ordering,
2178        gc,
2179        clip_x_origin,
2180        clip_y_origin,
2181        rectangles: Cow::Borrowed(rectangles),
2182    };
2183    let (bytes, fds) = request0.serialize();
2184    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2185    assert_eq!(slices.len(), bytes.len());
2186    conn.send_request_without_reply(&slices, fds)
2187}
2188
2189/// Destroys a graphics context.
2190///
2191/// Destroys the specified `gc` and all associated storage.
2192///
2193/// # Fields
2194///
2195/// * `gc` - The graphics context to destroy.
2196///
2197/// # Errors
2198///
2199/// * `GContext` - The specified graphics context does not exist.
2200pub fn free_gc<Conn>(conn: &Conn, gc: Gcontext) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2201where
2202    Conn: RequestConnection + ?Sized,
2203{
2204    let request0 = FreeGCRequest {
2205        gc,
2206    };
2207    let (bytes, fds) = request0.serialize();
2208    let slices = [IoSlice::new(&bytes[0])];
2209    assert_eq!(slices.len(), bytes.len());
2210    conn.send_request_without_reply(&slices, fds)
2211}
2212
2213pub fn clear_area<Conn>(conn: &Conn, exposures: bool, window: Window, x: i16, y: i16, width: u16, height: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2214where
2215    Conn: RequestConnection + ?Sized,
2216{
2217    let request0 = ClearAreaRequest {
2218        exposures,
2219        window,
2220        x,
2221        y,
2222        width,
2223        height,
2224    };
2225    let (bytes, fds) = request0.serialize();
2226    let slices = [IoSlice::new(&bytes[0])];
2227    assert_eq!(slices.len(), bytes.len());
2228    conn.send_request_without_reply(&slices, fds)
2229}
2230
2231/// copy areas.
2232///
2233/// Copies the specified rectangle from `src_drawable` to `dst_drawable`.
2234///
2235/// # Fields
2236///
2237/// * `dst_drawable` - The destination drawable (Window or Pixmap).
2238/// * `src_drawable` - The source drawable (Window or Pixmap).
2239/// * `gc` - The graphics context to use.
2240/// * `src_x` - The source X coordinate.
2241/// * `src_y` - The source Y coordinate.
2242/// * `dst_x` - The destination X coordinate.
2243/// * `dst_y` - The destination Y coordinate.
2244/// * `width` - The width of the area to copy (in pixels).
2245/// * `height` - The height of the area to copy (in pixels).
2246///
2247/// # Errors
2248///
2249/// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
2250/// * `GContext` - The specified graphics context does not exist.
2251/// * `Match` - `src_drawable` has a different root or depth than `dst_drawable`.
2252pub fn copy_area<Conn>(conn: &Conn, src_drawable: Drawable, dst_drawable: Drawable, gc: Gcontext, src_x: i16, src_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2253where
2254    Conn: RequestConnection + ?Sized,
2255{
2256    let request0 = CopyAreaRequest {
2257        src_drawable,
2258        dst_drawable,
2259        gc,
2260        src_x,
2261        src_y,
2262        dst_x,
2263        dst_y,
2264        width,
2265        height,
2266    };
2267    let (bytes, fds) = request0.serialize();
2268    let slices = [IoSlice::new(&bytes[0])];
2269    assert_eq!(slices.len(), bytes.len());
2270    conn.send_request_without_reply(&slices, fds)
2271}
2272
2273pub fn copy_plane<Conn>(conn: &Conn, src_drawable: Drawable, dst_drawable: Drawable, gc: Gcontext, src_x: i16, src_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16, bit_plane: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2274where
2275    Conn: RequestConnection + ?Sized,
2276{
2277    let request0 = CopyPlaneRequest {
2278        src_drawable,
2279        dst_drawable,
2280        gc,
2281        src_x,
2282        src_y,
2283        dst_x,
2284        dst_y,
2285        width,
2286        height,
2287        bit_plane,
2288    };
2289    let (bytes, fds) = request0.serialize();
2290    let slices = [IoSlice::new(&bytes[0])];
2291    assert_eq!(slices.len(), bytes.len());
2292    conn.send_request_without_reply(&slices, fds)
2293}
2294
2295pub fn poly_point<'c, 'input, Conn>(conn: &'c Conn, coordinate_mode: CoordMode, drawable: Drawable, gc: Gcontext, points: &'input [Point]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2296where
2297    Conn: RequestConnection + ?Sized,
2298{
2299    let request0 = PolyPointRequest {
2300        coordinate_mode,
2301        drawable,
2302        gc,
2303        points: Cow::Borrowed(points),
2304    };
2305    let (bytes, fds) = request0.serialize();
2306    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2307    assert_eq!(slices.len(), bytes.len());
2308    conn.send_request_without_reply(&slices, fds)
2309}
2310
2311/// draw lines.
2312///
2313/// Draws `points_len`-1 lines between each pair of points (point[i], point[i+1])
2314/// in the `points` array. The lines are drawn in the order listed in the array.
2315/// They join correctly at all intermediate points, and if the first and last
2316/// points coincide, the first and last lines also join correctly. For any given
2317/// line, a pixel is not drawn more than once. If thin (zero line-width) lines
2318/// intersect, the intersecting pixels are drawn multiple times. If wide lines
2319/// intersect, the intersecting pixels are drawn only once, as though the entire
2320/// request were a single, filled shape.
2321///
2322/// # Fields
2323///
2324/// * `drawable` - The drawable to draw the line(s) on.
2325/// * `gc` - The graphics context to use.
2326/// * `points_len` - The number of `xcb_point_t` structures in `points`.
2327/// * `points` - An array of points.
2328/// * `coordinate_mode` -
2329///
2330/// # Errors
2331///
2332/// * `Drawable` - TODO: reasons?
2333/// * `GContext` - TODO: reasons?
2334/// * `Match` - TODO: reasons?
2335/// * `Value` - TODO: reasons?
2336///
2337/// # Example
2338///
2339/// ```text
2340/// /*
2341///  * Draw a straight line.
2342///  *
2343///  */
2344/// void my_example(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc) {
2345///     xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, drawable, gc, 2,
2346///                   (xcb_point_t[]) { {10, 10}, {100, 10} });
2347///     xcb_flush(conn);
2348/// }
2349/// ```
2350pub fn poly_line<'c, 'input, Conn>(conn: &'c Conn, coordinate_mode: CoordMode, drawable: Drawable, gc: Gcontext, points: &'input [Point]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2351where
2352    Conn: RequestConnection + ?Sized,
2353{
2354    let request0 = PolyLineRequest {
2355        coordinate_mode,
2356        drawable,
2357        gc,
2358        points: Cow::Borrowed(points),
2359    };
2360    let (bytes, fds) = request0.serialize();
2361    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2362    assert_eq!(slices.len(), bytes.len());
2363    conn.send_request_without_reply(&slices, fds)
2364}
2365
2366/// draw lines.
2367///
2368/// Draws multiple, unconnected lines. For each segment, a line is drawn between
2369/// (x1, y1) and (x2, y2). The lines are drawn in the order listed in the array of
2370/// `xcb_segment_t` structures and does not perform joining at coincident
2371/// endpoints. For any given line, a pixel is not drawn more than once. If lines
2372/// intersect, the intersecting pixels are drawn multiple times.
2373///
2374/// TODO: include the xcb_segment_t data structure
2375///
2376/// TODO: an example
2377///
2378/// # Fields
2379///
2380/// * `drawable` - A drawable (Window or Pixmap) to draw on.
2381/// * `gc` - The graphics context to use.
2382///
2383/// TODO: document which attributes of a gc are used
2384/// * `segments_len` - The number of `xcb_segment_t` structures in `segments`.
2385/// * `segments` - An array of `xcb_segment_t` structures.
2386///
2387/// # Errors
2388///
2389/// * `Drawable` - The specified `drawable` does not exist.
2390/// * `GContext` - The specified `gc` does not exist.
2391/// * `Match` - TODO: reasons?
2392pub fn poly_segment<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, gc: Gcontext, segments: &'input [Segment]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2393where
2394    Conn: RequestConnection + ?Sized,
2395{
2396    let request0 = PolySegmentRequest {
2397        drawable,
2398        gc,
2399        segments: Cow::Borrowed(segments),
2400    };
2401    let (bytes, fds) = request0.serialize();
2402    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2403    assert_eq!(slices.len(), bytes.len());
2404    conn.send_request_without_reply(&slices, fds)
2405}
2406
2407pub fn poly_rectangle<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, gc: Gcontext, rectangles: &'input [Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2408where
2409    Conn: RequestConnection + ?Sized,
2410{
2411    let request0 = PolyRectangleRequest {
2412        drawable,
2413        gc,
2414        rectangles: Cow::Borrowed(rectangles),
2415    };
2416    let (bytes, fds) = request0.serialize();
2417    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2418    assert_eq!(slices.len(), bytes.len());
2419    conn.send_request_without_reply(&slices, fds)
2420}
2421
2422pub fn poly_arc<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, gc: Gcontext, arcs: &'input [Arc]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2423where
2424    Conn: RequestConnection + ?Sized,
2425{
2426    let request0 = PolyArcRequest {
2427        drawable,
2428        gc,
2429        arcs: Cow::Borrowed(arcs),
2430    };
2431    let (bytes, fds) = request0.serialize();
2432    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2433    assert_eq!(slices.len(), bytes.len());
2434    conn.send_request_without_reply(&slices, fds)
2435}
2436
2437pub fn fill_poly<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, gc: Gcontext, shape: PolyShape, coordinate_mode: CoordMode, points: &'input [Point]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2438where
2439    Conn: RequestConnection + ?Sized,
2440{
2441    let request0 = FillPolyRequest {
2442        drawable,
2443        gc,
2444        shape,
2445        coordinate_mode,
2446        points: Cow::Borrowed(points),
2447    };
2448    let (bytes, fds) = request0.serialize();
2449    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2450    assert_eq!(slices.len(), bytes.len());
2451    conn.send_request_without_reply(&slices, fds)
2452}
2453
2454/// Fills rectangles.
2455///
2456/// Fills the specified rectangle(s) in the order listed in the array. For any
2457/// given rectangle, each pixel is not drawn more than once. If rectangles
2458/// intersect, the intersecting pixels are drawn multiple times.
2459///
2460/// # Fields
2461///
2462/// * `drawable` - The drawable (Window or Pixmap) to draw on.
2463/// * `gc` - The graphics context to use.
2464///
2465/// The following graphics context components are used: function, plane-mask,
2466/// fill-style, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
2467///
2468/// The following graphics context mode-dependent components are used:
2469/// foreground, background, tile, stipple, tile-stipple-x-origin, and
2470/// tile-stipple-y-origin.
2471/// * `rectangles_len` - The number of `xcb_rectangle_t` structures in `rectangles`.
2472/// * `rectangles` - The rectangles to fill.
2473///
2474/// # Errors
2475///
2476/// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
2477/// * `GContext` - The specified graphics context does not exist.
2478/// * `Match` - TODO: reasons?
2479pub fn poly_fill_rectangle<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, gc: Gcontext, rectangles: &'input [Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2480where
2481    Conn: RequestConnection + ?Sized,
2482{
2483    let request0 = PolyFillRectangleRequest {
2484        drawable,
2485        gc,
2486        rectangles: Cow::Borrowed(rectangles),
2487    };
2488    let (bytes, fds) = request0.serialize();
2489    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2490    assert_eq!(slices.len(), bytes.len());
2491    conn.send_request_without_reply(&slices, fds)
2492}
2493
2494pub fn poly_fill_arc<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, gc: Gcontext, arcs: &'input [Arc]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2495where
2496    Conn: RequestConnection + ?Sized,
2497{
2498    let request0 = PolyFillArcRequest {
2499        drawable,
2500        gc,
2501        arcs: Cow::Borrowed(arcs),
2502    };
2503    let (bytes, fds) = request0.serialize();
2504    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2505    assert_eq!(slices.len(), bytes.len());
2506    conn.send_request_without_reply(&slices, fds)
2507}
2508
2509pub fn put_image<'c, 'input, Conn>(conn: &'c Conn, format: ImageFormat, drawable: Drawable, gc: Gcontext, width: u16, height: u16, dst_x: i16, dst_y: i16, left_pad: u8, depth: u8, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2510where
2511    Conn: RequestConnection + ?Sized,
2512{
2513    let request0 = PutImageRequest {
2514        format,
2515        drawable,
2516        gc,
2517        width,
2518        height,
2519        dst_x,
2520        dst_y,
2521        left_pad,
2522        depth,
2523        data: Cow::Borrowed(data),
2524    };
2525    let (bytes, fds) = request0.serialize();
2526    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2527    assert_eq!(slices.len(), bytes.len());
2528    conn.send_request_without_reply(&slices, fds)
2529}
2530
2531pub fn get_image<Conn>(conn: &Conn, format: ImageFormat, drawable: Drawable, x: i16, y: i16, width: u16, height: u16, plane_mask: u32) -> Result<Cookie<'_, Conn, GetImageReply>, ConnectionError>
2532where
2533    Conn: RequestConnection + ?Sized,
2534{
2535    let request0 = GetImageRequest {
2536        format,
2537        drawable,
2538        x,
2539        y,
2540        width,
2541        height,
2542        plane_mask,
2543    };
2544    let (bytes, fds) = request0.serialize();
2545    let slices = [IoSlice::new(&bytes[0])];
2546    assert_eq!(slices.len(), bytes.len());
2547    conn.send_request_with_reply(&slices, fds)
2548}
2549
2550pub fn poly_text8<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, gc: Gcontext, x: i16, y: i16, items: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2551where
2552    Conn: RequestConnection + ?Sized,
2553{
2554    let request0 = PolyText8Request {
2555        drawable,
2556        gc,
2557        x,
2558        y,
2559        items: Cow::Borrowed(items),
2560    };
2561    let (bytes, fds) = request0.serialize();
2562    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2563    assert_eq!(slices.len(), bytes.len());
2564    conn.send_request_without_reply(&slices, fds)
2565}
2566
2567pub fn poly_text16<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, gc: Gcontext, x: i16, y: i16, items: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2568where
2569    Conn: RequestConnection + ?Sized,
2570{
2571    let request0 = PolyText16Request {
2572        drawable,
2573        gc,
2574        x,
2575        y,
2576        items: Cow::Borrowed(items),
2577    };
2578    let (bytes, fds) = request0.serialize();
2579    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2580    assert_eq!(slices.len(), bytes.len());
2581    conn.send_request_without_reply(&slices, fds)
2582}
2583
2584/// Draws text.
2585///
2586/// Fills the destination rectangle with the background pixel from `gc`, then
2587/// paints the text with the foreground pixel from `gc`. The upper-left corner of
2588/// the filled rectangle is at [x, y - font-ascent]. The width is overall-width,
2589/// the height is font-ascent + font-descent. The overall-width, font-ascent and
2590/// font-descent are as returned by `xcb_query_text_extents` (TODO).
2591///
2592/// Note that using X core fonts is deprecated (but still supported) in favor of
2593/// client-side rendering using Xft.
2594///
2595/// # Fields
2596///
2597/// * `drawable` - The drawable (Window or Pixmap) to draw text on.
2598/// * `string_len` - The length of the `string`. Note that this parameter limited by 255 due to
2599/// using 8 bits!
2600/// * `string` - The string to draw. Only the first 255 characters are relevant due to the data
2601/// type of `string_len`.
2602/// * `x` - The x coordinate of the first character, relative to the origin of `drawable`.
2603/// * `y` - The y coordinate of the first character, relative to the origin of `drawable`.
2604/// * `gc` - The graphics context to use.
2605///
2606/// The following graphics context components are used: plane-mask, foreground,
2607/// background, font, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
2608///
2609/// # Errors
2610///
2611/// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
2612/// * `GContext` - The specified graphics context does not exist.
2613/// * `Match` - TODO: reasons?
2614///
2615/// # See
2616///
2617/// * `ImageText16`: request
2618pub fn image_text8<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, gc: Gcontext, x: i16, y: i16, string: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2619where
2620    Conn: RequestConnection + ?Sized,
2621{
2622    let request0 = ImageText8Request {
2623        drawable,
2624        gc,
2625        x,
2626        y,
2627        string: Cow::Borrowed(string),
2628    };
2629    let (bytes, fds) = request0.serialize();
2630    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2631    assert_eq!(slices.len(), bytes.len());
2632    conn.send_request_without_reply(&slices, fds)
2633}
2634
2635/// Draws text.
2636///
2637/// Fills the destination rectangle with the background pixel from `gc`, then
2638/// paints the text with the foreground pixel from `gc`. The upper-left corner of
2639/// the filled rectangle is at [x, y - font-ascent]. The width is overall-width,
2640/// the height is font-ascent + font-descent. The overall-width, font-ascent and
2641/// font-descent are as returned by `xcb_query_text_extents` (TODO).
2642///
2643/// Note that using X core fonts is deprecated (but still supported) in favor of
2644/// client-side rendering using Xft.
2645///
2646/// # Fields
2647///
2648/// * `drawable` - The drawable (Window or Pixmap) to draw text on.
2649/// * `string_len` - The length of the `string` in characters. Note that this parameter limited by
2650/// 255 due to using 8 bits!
2651/// * `string` - The string to draw. Only the first 255 characters are relevant due to the data
2652/// type of `string_len`. Every character uses 2 bytes (hence the 16 in this
2653/// request's name).
2654/// * `x` - The x coordinate of the first character, relative to the origin of `drawable`.
2655/// * `y` - The y coordinate of the first character, relative to the origin of `drawable`.
2656/// * `gc` - The graphics context to use.
2657///
2658/// The following graphics context components are used: plane-mask, foreground,
2659/// background, font, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
2660///
2661/// # Errors
2662///
2663/// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
2664/// * `GContext` - The specified graphics context does not exist.
2665/// * `Match` - TODO: reasons?
2666///
2667/// # See
2668///
2669/// * `ImageText8`: request
2670pub fn image_text16<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, gc: Gcontext, x: i16, y: i16, string: &'input [Char2b]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2671where
2672    Conn: RequestConnection + ?Sized,
2673{
2674    let request0 = ImageText16Request {
2675        drawable,
2676        gc,
2677        x,
2678        y,
2679        string: Cow::Borrowed(string),
2680    };
2681    let (bytes, fds) = request0.serialize();
2682    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2683    assert_eq!(slices.len(), bytes.len());
2684    conn.send_request_without_reply(&slices, fds)
2685}
2686
2687pub fn create_colormap<Conn>(conn: &Conn, alloc: ColormapAlloc, mid: Colormap, window: Window, visual: Visualid) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2688where
2689    Conn: RequestConnection + ?Sized,
2690{
2691    let request0 = CreateColormapRequest {
2692        alloc,
2693        mid,
2694        window,
2695        visual,
2696    };
2697    let (bytes, fds) = request0.serialize();
2698    let slices = [IoSlice::new(&bytes[0])];
2699    assert_eq!(slices.len(), bytes.len());
2700    conn.send_request_without_reply(&slices, fds)
2701}
2702
2703pub fn free_colormap<Conn>(conn: &Conn, cmap: Colormap) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2704where
2705    Conn: RequestConnection + ?Sized,
2706{
2707    let request0 = FreeColormapRequest {
2708        cmap,
2709    };
2710    let (bytes, fds) = request0.serialize();
2711    let slices = [IoSlice::new(&bytes[0])];
2712    assert_eq!(slices.len(), bytes.len());
2713    conn.send_request_without_reply(&slices, fds)
2714}
2715
2716pub fn copy_colormap_and_free<Conn>(conn: &Conn, mid: Colormap, src_cmap: Colormap) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2717where
2718    Conn: RequestConnection + ?Sized,
2719{
2720    let request0 = CopyColormapAndFreeRequest {
2721        mid,
2722        src_cmap,
2723    };
2724    let (bytes, fds) = request0.serialize();
2725    let slices = [IoSlice::new(&bytes[0])];
2726    assert_eq!(slices.len(), bytes.len());
2727    conn.send_request_without_reply(&slices, fds)
2728}
2729
2730pub fn install_colormap<Conn>(conn: &Conn, cmap: Colormap) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2731where
2732    Conn: RequestConnection + ?Sized,
2733{
2734    let request0 = InstallColormapRequest {
2735        cmap,
2736    };
2737    let (bytes, fds) = request0.serialize();
2738    let slices = [IoSlice::new(&bytes[0])];
2739    assert_eq!(slices.len(), bytes.len());
2740    conn.send_request_without_reply(&slices, fds)
2741}
2742
2743pub fn uninstall_colormap<Conn>(conn: &Conn, cmap: Colormap) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2744where
2745    Conn: RequestConnection + ?Sized,
2746{
2747    let request0 = UninstallColormapRequest {
2748        cmap,
2749    };
2750    let (bytes, fds) = request0.serialize();
2751    let slices = [IoSlice::new(&bytes[0])];
2752    assert_eq!(slices.len(), bytes.len());
2753    conn.send_request_without_reply(&slices, fds)
2754}
2755
2756pub fn list_installed_colormaps<Conn>(conn: &Conn, window: Window) -> Result<Cookie<'_, Conn, ListInstalledColormapsReply>, ConnectionError>
2757where
2758    Conn: RequestConnection + ?Sized,
2759{
2760    let request0 = ListInstalledColormapsRequest {
2761        window,
2762    };
2763    let (bytes, fds) = request0.serialize();
2764    let slices = [IoSlice::new(&bytes[0])];
2765    assert_eq!(slices.len(), bytes.len());
2766    conn.send_request_with_reply(&slices, fds)
2767}
2768
2769/// Allocate a color.
2770///
2771/// Allocates a read-only colormap entry corresponding to the closest RGB value
2772/// supported by the hardware. If you are using TrueColor, you can take a shortcut
2773/// and directly calculate the color pixel value to avoid the round trip. But, for
2774/// example, on 16-bit color setups (VNC), you can easily get the closest supported
2775/// RGB value to the RGB value you are specifying.
2776///
2777/// # Fields
2778///
2779/// * `cmap` - TODO
2780/// * `red` - The red value of your color.
2781/// * `green` - The green value of your color.
2782/// * `blue` - The blue value of your color.
2783///
2784/// # Errors
2785///
2786/// * `Colormap` - The specified colormap `cmap` does not exist.
2787pub fn alloc_color<Conn>(conn: &Conn, cmap: Colormap, red: u16, green: u16, blue: u16) -> Result<Cookie<'_, Conn, AllocColorReply>, ConnectionError>
2788where
2789    Conn: RequestConnection + ?Sized,
2790{
2791    let request0 = AllocColorRequest {
2792        cmap,
2793        red,
2794        green,
2795        blue,
2796    };
2797    let (bytes, fds) = request0.serialize();
2798    let slices = [IoSlice::new(&bytes[0])];
2799    assert_eq!(slices.len(), bytes.len());
2800    conn.send_request_with_reply(&slices, fds)
2801}
2802
2803pub fn alloc_named_color<'c, 'input, Conn>(conn: &'c Conn, cmap: Colormap, name: &'input [u8]) -> Result<Cookie<'c, Conn, AllocNamedColorReply>, ConnectionError>
2804where
2805    Conn: RequestConnection + ?Sized,
2806{
2807    let request0 = AllocNamedColorRequest {
2808        cmap,
2809        name: Cow::Borrowed(name),
2810    };
2811    let (bytes, fds) = request0.serialize();
2812    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2813    assert_eq!(slices.len(), bytes.len());
2814    conn.send_request_with_reply(&slices, fds)
2815}
2816
2817pub fn alloc_color_cells<Conn>(conn: &Conn, contiguous: bool, cmap: Colormap, colors: u16, planes: u16) -> Result<Cookie<'_, Conn, AllocColorCellsReply>, ConnectionError>
2818where
2819    Conn: RequestConnection + ?Sized,
2820{
2821    let request0 = AllocColorCellsRequest {
2822        contiguous,
2823        cmap,
2824        colors,
2825        planes,
2826    };
2827    let (bytes, fds) = request0.serialize();
2828    let slices = [IoSlice::new(&bytes[0])];
2829    assert_eq!(slices.len(), bytes.len());
2830    conn.send_request_with_reply(&slices, fds)
2831}
2832
2833pub fn alloc_color_planes<Conn>(conn: &Conn, contiguous: bool, cmap: Colormap, colors: u16, reds: u16, greens: u16, blues: u16) -> Result<Cookie<'_, Conn, AllocColorPlanesReply>, ConnectionError>
2834where
2835    Conn: RequestConnection + ?Sized,
2836{
2837    let request0 = AllocColorPlanesRequest {
2838        contiguous,
2839        cmap,
2840        colors,
2841        reds,
2842        greens,
2843        blues,
2844    };
2845    let (bytes, fds) = request0.serialize();
2846    let slices = [IoSlice::new(&bytes[0])];
2847    assert_eq!(slices.len(), bytes.len());
2848    conn.send_request_with_reply(&slices, fds)
2849}
2850
2851pub fn free_colors<'c, 'input, Conn>(conn: &'c Conn, cmap: Colormap, plane_mask: u32, pixels: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2852where
2853    Conn: RequestConnection + ?Sized,
2854{
2855    let request0 = FreeColorsRequest {
2856        cmap,
2857        plane_mask,
2858        pixels: Cow::Borrowed(pixels),
2859    };
2860    let (bytes, fds) = request0.serialize();
2861    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2862    assert_eq!(slices.len(), bytes.len());
2863    conn.send_request_without_reply(&slices, fds)
2864}
2865
2866pub fn store_colors<'c, 'input, Conn>(conn: &'c Conn, cmap: Colormap, items: &'input [Coloritem]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2867where
2868    Conn: RequestConnection + ?Sized,
2869{
2870    let request0 = StoreColorsRequest {
2871        cmap,
2872        items: Cow::Borrowed(items),
2873    };
2874    let (bytes, fds) = request0.serialize();
2875    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2876    assert_eq!(slices.len(), bytes.len());
2877    conn.send_request_without_reply(&slices, fds)
2878}
2879
2880pub fn store_named_color<'c, 'input, Conn>(conn: &'c Conn, flags: ColorFlag, cmap: Colormap, pixel: u32, name: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2881where
2882    Conn: RequestConnection + ?Sized,
2883{
2884    let request0 = StoreNamedColorRequest {
2885        flags,
2886        cmap,
2887        pixel,
2888        name: Cow::Borrowed(name),
2889    };
2890    let (bytes, fds) = request0.serialize();
2891    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2892    assert_eq!(slices.len(), bytes.len());
2893    conn.send_request_without_reply(&slices, fds)
2894}
2895
2896pub fn query_colors<'c, 'input, Conn>(conn: &'c Conn, cmap: Colormap, pixels: &'input [u32]) -> Result<Cookie<'c, Conn, QueryColorsReply>, ConnectionError>
2897where
2898    Conn: RequestConnection + ?Sized,
2899{
2900    let request0 = QueryColorsRequest {
2901        cmap,
2902        pixels: Cow::Borrowed(pixels),
2903    };
2904    let (bytes, fds) = request0.serialize();
2905    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2906    assert_eq!(slices.len(), bytes.len());
2907    conn.send_request_with_reply(&slices, fds)
2908}
2909
2910pub fn lookup_color<'c, 'input, Conn>(conn: &'c Conn, cmap: Colormap, name: &'input [u8]) -> Result<Cookie<'c, Conn, LookupColorReply>, ConnectionError>
2911where
2912    Conn: RequestConnection + ?Sized,
2913{
2914    let request0 = LookupColorRequest {
2915        cmap,
2916        name: Cow::Borrowed(name),
2917    };
2918    let (bytes, fds) = request0.serialize();
2919    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
2920    assert_eq!(slices.len(), bytes.len());
2921    conn.send_request_with_reply(&slices, fds)
2922}
2923
2924pub fn create_cursor<Conn, A>(conn: &Conn, cid: Cursor, source: Pixmap, mask: A, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16, x: u16, y: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2925where
2926    Conn: RequestConnection + ?Sized,
2927    A: Into<Pixmap>,
2928{
2929    let mask: Pixmap = mask.into();
2930    let request0 = CreateCursorRequest {
2931        cid,
2932        source,
2933        mask,
2934        fore_red,
2935        fore_green,
2936        fore_blue,
2937        back_red,
2938        back_green,
2939        back_blue,
2940        x,
2941        y,
2942    };
2943    let (bytes, fds) = request0.serialize();
2944    let slices = [IoSlice::new(&bytes[0])];
2945    assert_eq!(slices.len(), bytes.len());
2946    conn.send_request_without_reply(&slices, fds)
2947}
2948
2949/// create cursor.
2950///
2951/// Creates a cursor from a font glyph. X provides a set of standard cursor shapes
2952/// in a special font named cursor. Applications are encouraged to use this
2953/// interface for their cursors because the font can be customized for the
2954/// individual display type.
2955///
2956/// All pixels which are set to 1 in the source will use the foreground color (as
2957/// specified by `fore_red`, `fore_green` and `fore_blue`). All pixels set to 0
2958/// will use the background color (as specified by `back_red`, `back_green` and
2959/// `back_blue`).
2960///
2961/// # Fields
2962///
2963/// * `cid` - The ID with which you will refer to the cursor, created by `xcb_generate_id`.
2964/// * `source_font` - In which font to look for the cursor glyph.
2965/// * `mask_font` - In which font to look for the mask glyph.
2966/// * `source_char` - The glyph of `source_font` to use.
2967/// * `mask_char` - The glyph of `mask_font` to use as a mask: Pixels which are set to 1 define
2968/// which source pixels are displayed. All pixels which are set to 0 are not
2969/// displayed.
2970/// * `fore_red` - The red value of the foreground color.
2971/// * `fore_green` - The green value of the foreground color.
2972/// * `fore_blue` - The blue value of the foreground color.
2973/// * `back_red` - The red value of the background color.
2974/// * `back_green` - The green value of the background color.
2975/// * `back_blue` - The blue value of the background color.
2976///
2977/// # Errors
2978///
2979/// * `Alloc` - The X server could not allocate the requested resources (no memory?).
2980/// * `Font` - The specified `source_font` or `mask_font` does not exist.
2981/// * `Value` - Either `source_char` or `mask_char` are not defined in `source_font` or `mask_font`, respectively.
2982pub fn create_glyph_cursor<Conn, A>(conn: &Conn, cid: Cursor, source_font: Font, mask_font: A, source_char: u16, mask_char: u16, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2983where
2984    Conn: RequestConnection + ?Sized,
2985    A: Into<Font>,
2986{
2987    let mask_font: Font = mask_font.into();
2988    let request0 = CreateGlyphCursorRequest {
2989        cid,
2990        source_font,
2991        mask_font,
2992        source_char,
2993        mask_char,
2994        fore_red,
2995        fore_green,
2996        fore_blue,
2997        back_red,
2998        back_green,
2999        back_blue,
3000    };
3001    let (bytes, fds) = request0.serialize();
3002    let slices = [IoSlice::new(&bytes[0])];
3003    assert_eq!(slices.len(), bytes.len());
3004    conn.send_request_without_reply(&slices, fds)
3005}
3006
3007/// Deletes a cursor.
3008///
3009/// Deletes the association between the cursor resource ID and the specified
3010/// cursor. The cursor is freed when no other resource references it.
3011///
3012/// # Fields
3013///
3014/// * `cursor` - The cursor to destroy.
3015///
3016/// # Errors
3017///
3018/// * `Cursor` - The specified cursor does not exist.
3019pub fn free_cursor<Conn>(conn: &Conn, cursor: Cursor) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3020where
3021    Conn: RequestConnection + ?Sized,
3022{
3023    let request0 = FreeCursorRequest {
3024        cursor,
3025    };
3026    let (bytes, fds) = request0.serialize();
3027    let slices = [IoSlice::new(&bytes[0])];
3028    assert_eq!(slices.len(), bytes.len());
3029    conn.send_request_without_reply(&slices, fds)
3030}
3031
3032pub fn recolor_cursor<Conn>(conn: &Conn, cursor: Cursor, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3033where
3034    Conn: RequestConnection + ?Sized,
3035{
3036    let request0 = RecolorCursorRequest {
3037        cursor,
3038        fore_red,
3039        fore_green,
3040        fore_blue,
3041        back_red,
3042        back_green,
3043        back_blue,
3044    };
3045    let (bytes, fds) = request0.serialize();
3046    let slices = [IoSlice::new(&bytes[0])];
3047    assert_eq!(slices.len(), bytes.len());
3048    conn.send_request_without_reply(&slices, fds)
3049}
3050
3051pub fn query_best_size<Conn>(conn: &Conn, class: QueryShapeOf, drawable: Drawable, width: u16, height: u16) -> Result<Cookie<'_, Conn, QueryBestSizeReply>, ConnectionError>
3052where
3053    Conn: RequestConnection + ?Sized,
3054{
3055    let request0 = QueryBestSizeRequest {
3056        class,
3057        drawable,
3058        width,
3059        height,
3060    };
3061    let (bytes, fds) = request0.serialize();
3062    let slices = [IoSlice::new(&bytes[0])];
3063    assert_eq!(slices.len(), bytes.len());
3064    conn.send_request_with_reply(&slices, fds)
3065}
3066
3067/// check if extension is present.
3068///
3069/// Determines if the specified extension is present on this X11 server.
3070///
3071/// Every extension has a unique `major_opcode` to identify requests, the minor
3072/// opcodes and request formats are extension-specific. If the extension provides
3073/// events and errors, the `first_event` and `first_error` fields in the reply are
3074/// set accordingly.
3075///
3076/// There should rarely be a need to use this request directly, XCB provides the
3077/// `xcb_get_extension_data` function instead.
3078///
3079/// # Fields
3080///
3081/// * `name_len` - The length of `name` in bytes.
3082/// * `name` - The name of the extension to query, for example "RANDR". This is case
3083/// sensitive!
3084///
3085/// # See
3086///
3087/// * `xdpyinfo`: program
3088/// * `xcb_get_extension_data`: function
3089pub fn query_extension<'c, 'input, Conn>(conn: &'c Conn, name: &'input [u8]) -> Result<Cookie<'c, Conn, QueryExtensionReply>, ConnectionError>
3090where
3091    Conn: RequestConnection + ?Sized,
3092{
3093    let request0 = QueryExtensionRequest {
3094        name: Cow::Borrowed(name),
3095    };
3096    let (bytes, fds) = request0.serialize();
3097    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
3098    assert_eq!(slices.len(), bytes.len());
3099    conn.send_request_with_reply(&slices, fds)
3100}
3101
3102pub fn list_extensions<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, ListExtensionsReply>, ConnectionError>
3103where
3104    Conn: RequestConnection + ?Sized,
3105{
3106    let request0 = ListExtensionsRequest;
3107    let (bytes, fds) = request0.serialize();
3108    let slices = [IoSlice::new(&bytes[0])];
3109    assert_eq!(slices.len(), bytes.len());
3110    conn.send_request_with_reply(&slices, fds)
3111}
3112
3113pub fn change_keyboard_mapping<'c, 'input, Conn>(conn: &'c Conn, keycode_count: u8, first_keycode: Keycode, keysyms_per_keycode: u8, keysyms: &'input [Keysym]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3114where
3115    Conn: RequestConnection + ?Sized,
3116{
3117    let request0 = ChangeKeyboardMappingRequest {
3118        keycode_count,
3119        first_keycode,
3120        keysyms_per_keycode,
3121        keysyms: Cow::Borrowed(keysyms),
3122    };
3123    let (bytes, fds) = request0.serialize();
3124    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
3125    assert_eq!(slices.len(), bytes.len());
3126    conn.send_request_without_reply(&slices, fds)
3127}
3128
3129pub fn get_keyboard_mapping<Conn>(conn: &Conn, first_keycode: Keycode, count: u8) -> Result<Cookie<'_, Conn, GetKeyboardMappingReply>, ConnectionError>
3130where
3131    Conn: RequestConnection + ?Sized,
3132{
3133    let request0 = GetKeyboardMappingRequest {
3134        first_keycode,
3135        count,
3136    };
3137    let (bytes, fds) = request0.serialize();
3138    let slices = [IoSlice::new(&bytes[0])];
3139    assert_eq!(slices.len(), bytes.len());
3140    conn.send_request_with_reply(&slices, fds)
3141}
3142
3143pub fn change_keyboard_control<'c, 'input, Conn>(conn: &'c Conn, value_list: &'input ChangeKeyboardControlAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3144where
3145    Conn: RequestConnection + ?Sized,
3146{
3147    let request0 = ChangeKeyboardControlRequest {
3148        value_list: Cow::Borrowed(value_list),
3149    };
3150    let (bytes, fds) = request0.serialize();
3151    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
3152    assert_eq!(slices.len(), bytes.len());
3153    conn.send_request_without_reply(&slices, fds)
3154}
3155
3156pub fn get_keyboard_control<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetKeyboardControlReply>, ConnectionError>
3157where
3158    Conn: RequestConnection + ?Sized,
3159{
3160    let request0 = GetKeyboardControlRequest;
3161    let (bytes, fds) = request0.serialize();
3162    let slices = [IoSlice::new(&bytes[0])];
3163    assert_eq!(slices.len(), bytes.len());
3164    conn.send_request_with_reply(&slices, fds)
3165}
3166
3167pub fn bell<Conn>(conn: &Conn, percent: i8) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3168where
3169    Conn: RequestConnection + ?Sized,
3170{
3171    let request0 = BellRequest {
3172        percent,
3173    };
3174    let (bytes, fds) = request0.serialize();
3175    let slices = [IoSlice::new(&bytes[0])];
3176    assert_eq!(slices.len(), bytes.len());
3177    conn.send_request_without_reply(&slices, fds)
3178}
3179
3180pub fn change_pointer_control<Conn>(conn: &Conn, acceleration_numerator: i16, acceleration_denominator: i16, threshold: i16, do_acceleration: bool, do_threshold: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3181where
3182    Conn: RequestConnection + ?Sized,
3183{
3184    let request0 = ChangePointerControlRequest {
3185        acceleration_numerator,
3186        acceleration_denominator,
3187        threshold,
3188        do_acceleration,
3189        do_threshold,
3190    };
3191    let (bytes, fds) = request0.serialize();
3192    let slices = [IoSlice::new(&bytes[0])];
3193    assert_eq!(slices.len(), bytes.len());
3194    conn.send_request_without_reply(&slices, fds)
3195}
3196
3197pub fn get_pointer_control<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetPointerControlReply>, ConnectionError>
3198where
3199    Conn: RequestConnection + ?Sized,
3200{
3201    let request0 = GetPointerControlRequest;
3202    let (bytes, fds) = request0.serialize();
3203    let slices = [IoSlice::new(&bytes[0])];
3204    assert_eq!(slices.len(), bytes.len());
3205    conn.send_request_with_reply(&slices, fds)
3206}
3207
3208pub fn set_screen_saver<Conn>(conn: &Conn, timeout: i16, interval: i16, prefer_blanking: Blanking, allow_exposures: Exposures) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3209where
3210    Conn: RequestConnection + ?Sized,
3211{
3212    let request0 = SetScreenSaverRequest {
3213        timeout,
3214        interval,
3215        prefer_blanking,
3216        allow_exposures,
3217    };
3218    let (bytes, fds) = request0.serialize();
3219    let slices = [IoSlice::new(&bytes[0])];
3220    assert_eq!(slices.len(), bytes.len());
3221    conn.send_request_without_reply(&slices, fds)
3222}
3223
3224pub fn get_screen_saver<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetScreenSaverReply>, ConnectionError>
3225where
3226    Conn: RequestConnection + ?Sized,
3227{
3228    let request0 = GetScreenSaverRequest;
3229    let (bytes, fds) = request0.serialize();
3230    let slices = [IoSlice::new(&bytes[0])];
3231    assert_eq!(slices.len(), bytes.len());
3232    conn.send_request_with_reply(&slices, fds)
3233}
3234
3235pub fn change_hosts<'c, 'input, Conn>(conn: &'c Conn, mode: HostMode, family: Family, address: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3236where
3237    Conn: RequestConnection + ?Sized,
3238{
3239    let request0 = ChangeHostsRequest {
3240        mode,
3241        family,
3242        address: Cow::Borrowed(address),
3243    };
3244    let (bytes, fds) = request0.serialize();
3245    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
3246    assert_eq!(slices.len(), bytes.len());
3247    conn.send_request_without_reply(&slices, fds)
3248}
3249
3250pub fn list_hosts<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, ListHostsReply>, ConnectionError>
3251where
3252    Conn: RequestConnection + ?Sized,
3253{
3254    let request0 = ListHostsRequest;
3255    let (bytes, fds) = request0.serialize();
3256    let slices = [IoSlice::new(&bytes[0])];
3257    assert_eq!(slices.len(), bytes.len());
3258    conn.send_request_with_reply(&slices, fds)
3259}
3260
3261pub fn set_access_control<Conn>(conn: &Conn, mode: AccessControl) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3262where
3263    Conn: RequestConnection + ?Sized,
3264{
3265    let request0 = SetAccessControlRequest {
3266        mode,
3267    };
3268    let (bytes, fds) = request0.serialize();
3269    let slices = [IoSlice::new(&bytes[0])];
3270    assert_eq!(slices.len(), bytes.len());
3271    conn.send_request_without_reply(&slices, fds)
3272}
3273
3274pub fn set_close_down_mode<Conn>(conn: &Conn, mode: CloseDown) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3275where
3276    Conn: RequestConnection + ?Sized,
3277{
3278    let request0 = SetCloseDownModeRequest {
3279        mode,
3280    };
3281    let (bytes, fds) = request0.serialize();
3282    let slices = [IoSlice::new(&bytes[0])];
3283    assert_eq!(slices.len(), bytes.len());
3284    conn.send_request_without_reply(&slices, fds)
3285}
3286
3287/// kills a client.
3288///
3289/// Forces a close down of the client that created the specified `resource`.
3290///
3291/// # Fields
3292///
3293/// * `resource` - Any resource belonging to the client (for example a Window), used to identify
3294/// the client connection.
3295///
3296/// The special value of `XCB_KILL_ALL_TEMPORARY`, the resources of all clients
3297/// that have terminated in `RetainTemporary` (TODO) are destroyed.
3298///
3299/// # Errors
3300///
3301/// * `Value` - The specified `resource` does not exist.
3302///
3303/// # See
3304///
3305/// * `xkill`: program
3306pub fn kill_client<Conn, A>(conn: &Conn, resource: A) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3307where
3308    Conn: RequestConnection + ?Sized,
3309    A: Into<u32>,
3310{
3311    let resource: u32 = resource.into();
3312    let request0 = KillClientRequest {
3313        resource,
3314    };
3315    let (bytes, fds) = request0.serialize();
3316    let slices = [IoSlice::new(&bytes[0])];
3317    assert_eq!(slices.len(), bytes.len());
3318    conn.send_request_without_reply(&slices, fds)
3319}
3320
3321pub fn rotate_properties<'c, 'input, Conn>(conn: &'c Conn, window: Window, delta: i16, atoms: &'input [Atom]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3322where
3323    Conn: RequestConnection + ?Sized,
3324{
3325    let request0 = RotatePropertiesRequest {
3326        window,
3327        delta,
3328        atoms: Cow::Borrowed(atoms),
3329    };
3330    let (bytes, fds) = request0.serialize();
3331    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
3332    assert_eq!(slices.len(), bytes.len());
3333    conn.send_request_without_reply(&slices, fds)
3334}
3335
3336pub fn force_screen_saver<Conn>(conn: &Conn, mode: ScreenSaver) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3337where
3338    Conn: RequestConnection + ?Sized,
3339{
3340    let request0 = ForceScreenSaverRequest {
3341        mode,
3342    };
3343    let (bytes, fds) = request0.serialize();
3344    let slices = [IoSlice::new(&bytes[0])];
3345    assert_eq!(slices.len(), bytes.len());
3346    conn.send_request_without_reply(&slices, fds)
3347}
3348
3349pub fn set_pointer_mapping<'c, 'input, Conn>(conn: &'c Conn, map: &'input [u8]) -> Result<Cookie<'c, Conn, SetPointerMappingReply>, ConnectionError>
3350where
3351    Conn: RequestConnection + ?Sized,
3352{
3353    let request0 = SetPointerMappingRequest {
3354        map: Cow::Borrowed(map),
3355    };
3356    let (bytes, fds) = request0.serialize();
3357    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
3358    assert_eq!(slices.len(), bytes.len());
3359    conn.send_request_with_reply(&slices, fds)
3360}
3361
3362pub fn get_pointer_mapping<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetPointerMappingReply>, ConnectionError>
3363where
3364    Conn: RequestConnection + ?Sized,
3365{
3366    let request0 = GetPointerMappingRequest;
3367    let (bytes, fds) = request0.serialize();
3368    let slices = [IoSlice::new(&bytes[0])];
3369    assert_eq!(slices.len(), bytes.len());
3370    conn.send_request_with_reply(&slices, fds)
3371}
3372
3373pub fn set_modifier_mapping<'c, 'input, Conn>(conn: &'c Conn, keycodes: &'input [Keycode]) -> Result<Cookie<'c, Conn, SetModifierMappingReply>, ConnectionError>
3374where
3375    Conn: RequestConnection + ?Sized,
3376{
3377    let request0 = SetModifierMappingRequest {
3378        keycodes: Cow::Borrowed(keycodes),
3379    };
3380    let (bytes, fds) = request0.serialize();
3381    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
3382    assert_eq!(slices.len(), bytes.len());
3383    conn.send_request_with_reply(&slices, fds)
3384}
3385
3386pub fn get_modifier_mapping<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetModifierMappingReply>, ConnectionError>
3387where
3388    Conn: RequestConnection + ?Sized,
3389{
3390    let request0 = GetModifierMappingRequest;
3391    let (bytes, fds) = request0.serialize();
3392    let slices = [IoSlice::new(&bytes[0])];
3393    assert_eq!(slices.len(), bytes.len());
3394    conn.send_request_with_reply(&slices, fds)
3395}
3396
3397pub fn no_operation<Conn>(conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3398where
3399    Conn: RequestConnection + ?Sized,
3400{
3401    let request0 = NoOperationRequest;
3402    let (bytes, fds) = request0.serialize();
3403    let slices = [IoSlice::new(&bytes[0])];
3404    assert_eq!(slices.len(), bytes.len());
3405    conn.send_request_without_reply(&slices, fds)
3406}
3407
3408/// Extension trait defining the requests of this extension.
3409pub trait ConnectionExt: RequestConnection {
3410    /// Creates a window.
3411    ///
3412    /// Creates an unmapped window as child of the specified `parent` window. A
3413    /// CreateNotify event will be generated. The new window is placed on top in the
3414    /// stacking order with respect to siblings.
3415    ///
3416    /// The coordinate system has the X axis horizontal and the Y axis vertical with
3417    /// the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms
3418    /// of pixels, and coincide with pixel centers. Each window and pixmap has its own
3419    /// coordinate system. For a window, the origin is inside the border at the inside,
3420    /// upper-left corner.
3421    ///
3422    /// The created window is not yet displayed (mapped), call `xcb_map_window` to
3423    /// display it.
3424    ///
3425    /// The created window will initially use the same cursor as its parent.
3426    ///
3427    /// # Fields
3428    ///
3429    /// * `wid` - The ID with which you will refer to the new window, created by
3430    /// `xcb_generate_id`.
3431    /// * `depth` - Specifies the new window's depth (TODO: what unit?).
3432    ///
3433    /// The special value `XCB_COPY_FROM_PARENT` means the depth is taken from the
3434    /// `parent` window.
3435    /// * `visual` - Specifies the id for the new window's visual.
3436    ///
3437    /// The special value `XCB_COPY_FROM_PARENT` means the visual is taken from the
3438    /// `parent` window.
3439    /// * `class` -
3440    /// * `parent` - The parent window of the new window.
3441    /// * `border_width` - TODO:
3442    ///
3443    /// Must be zero if the `class` is `InputOnly` or a `xcb_match_error_t` occurs.
3444    /// * `x` - The X coordinate of the new window.
3445    /// * `y` - The Y coordinate of the new window.
3446    /// * `width` - The width of the new window.
3447    /// * `height` - The height of the new window.
3448    ///
3449    /// # Errors
3450    ///
3451    /// * `Colormap` - TODO: reasons?
3452    /// * `Match` - TODO: reasons?
3453    /// * `Cursor` - TODO: reasons?
3454    /// * `Pixmap` - TODO: reasons?
3455    /// * `Value` - TODO: reasons?
3456    /// * `Window` - TODO: reasons?
3457    /// * `Alloc` - The X server could not allocate the requested resources (no memory?).
3458    ///
3459    /// # See
3460    ///
3461    /// * `xcb_generate_id`: function
3462    /// * `MapWindow`: request
3463    /// * `CreateNotify`: event
3464    fn create_window<'c, 'input>(&'c self, depth: u8, wid: Window, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, class: WindowClass, visual: Visualid, value_list: &'input CreateWindowAux) -> Result<VoidCookie<'c, Self>, ConnectionError>
3465    {
3466        create_window(self, depth, wid, parent, x, y, width, height, border_width, class, visual, value_list)
3467    }
3468    /// change window attributes.
3469    ///
3470    /// Changes the attributes specified by `value_mask` for the specified `window`.
3471    ///
3472    /// # Fields
3473    ///
3474    /// * `window` - The window to change.
3475    /// * `value_mask` -
3476    /// * `value_list` - Values for each of the attributes specified in the bitmask `value_mask`. The
3477    /// order has to correspond to the order of possible `value_mask` bits. See the
3478    /// example.
3479    ///
3480    /// # Errors
3481    ///
3482    /// * `Access` - TODO: reasons?
3483    /// * `Colormap` - TODO: reasons?
3484    /// * `Cursor` - TODO: reasons?
3485    /// * `Match` - TODO: reasons?
3486    /// * `Pixmap` - TODO: reasons?
3487    /// * `Value` - TODO: reasons?
3488    /// * `Window` - The specified `window` does not exist.
3489    fn change_window_attributes<'c, 'input>(&'c self, window: Window, value_list: &'input ChangeWindowAttributesAux) -> Result<VoidCookie<'c, Self>, ConnectionError>
3490    {
3491        change_window_attributes(self, window, value_list)
3492    }
3493    /// Gets window attributes.
3494    ///
3495    /// Gets the current attributes for the specified `window`.
3496    ///
3497    /// # Fields
3498    ///
3499    /// * `window` - The window to get the attributes from.
3500    ///
3501    /// # Errors
3502    ///
3503    /// * `Window` - The specified `window` does not exist.
3504    /// * `Drawable` - TODO: reasons?
3505    fn get_window_attributes(&self, window: Window) -> Result<Cookie<'_, Self, GetWindowAttributesReply>, ConnectionError>
3506    {
3507        get_window_attributes(self, window)
3508    }
3509    /// Destroys a window.
3510    ///
3511    /// Destroys the specified window and all of its subwindows. A DestroyNotify event
3512    /// is generated for each destroyed window (a DestroyNotify event is first generated
3513    /// for any given window's inferiors). If the window was mapped, it will be
3514    /// automatically unmapped before destroying.
3515    ///
3516    /// Calling DestroyWindow on the root window will do nothing.
3517    ///
3518    /// # Fields
3519    ///
3520    /// * `window` - The window to destroy.
3521    ///
3522    /// # Errors
3523    ///
3524    /// * `Window` - The specified window does not exist.
3525    ///
3526    /// # See
3527    ///
3528    /// * `DestroyNotify`: event
3529    /// * `MapWindow`: request
3530    /// * `UnmapWindow`: request
3531    fn destroy_window(&self, window: Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
3532    {
3533        destroy_window(self, window)
3534    }
3535    fn destroy_subwindows(&self, window: Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
3536    {
3537        destroy_subwindows(self, window)
3538    }
3539    /// Changes a client's save set.
3540    ///
3541    /// TODO: explain what the save set is for.
3542    ///
3543    /// This function either adds or removes the specified window to the client's (your
3544    /// application's) save set.
3545    ///
3546    /// # Fields
3547    ///
3548    /// * `mode` - Insert to add the specified window to the save set or Delete to delete it from the save set.
3549    /// * `window` - The window to add or delete to/from your save set.
3550    ///
3551    /// # Errors
3552    ///
3553    /// * `Match` - You created the specified window. This does not make sense, you can only add
3554    /// windows created by other clients to your save set.
3555    /// * `Value` - You specified an invalid mode.
3556    /// * `Window` - The specified window does not exist.
3557    ///
3558    /// # See
3559    ///
3560    /// * `ReparentWindow`: request
3561    fn change_save_set(&self, mode: SetMode, window: Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
3562    {
3563        change_save_set(self, mode, window)
3564    }
3565    /// Reparents a window.
3566    ///
3567    /// Makes the specified window a child of the specified parent window. If the
3568    /// window is mapped, it will automatically be unmapped before reparenting and
3569    /// re-mapped after reparenting. The window is placed in the stacking order on top
3570    /// with respect to sibling windows.
3571    ///
3572    /// After reparenting, a ReparentNotify event is generated.
3573    ///
3574    /// # Fields
3575    ///
3576    /// * `window` - The window to reparent.
3577    /// * `parent` - The new parent of the window.
3578    /// * `x` - The X position of the window within its new parent.
3579    /// * `y` - The Y position of the window within its new parent.
3580    ///
3581    /// # Errors
3582    ///
3583    /// * `Match` - The new parent window is not on the same screen as the old parent window.
3584    /// 
3585    /// The new parent window is the specified window or an inferior of the specified window.
3586    /// 
3587    /// The new parent is InputOnly and the window is not.
3588    /// 
3589    /// The specified window has a ParentRelative background and the new parent window is not the same depth as the specified window.
3590    /// * `Window` - The specified window does not exist.
3591    ///
3592    /// # See
3593    ///
3594    /// * `ReparentNotify`: event
3595    /// * `MapWindow`: request
3596    /// * `UnmapWindow`: request
3597    fn reparent_window(&self, window: Window, parent: Window, x: i16, y: i16) -> Result<VoidCookie<'_, Self>, ConnectionError>
3598    {
3599        reparent_window(self, window, parent, x, y)
3600    }
3601    /// Makes a window visible.
3602    ///
3603    /// Maps the specified window. This means making the window visible (as long as its
3604    /// parent is visible).
3605    ///
3606    /// This MapWindow request will be translated to a MapRequest request if a window
3607    /// manager is running. The window manager then decides to either map the window or
3608    /// not. Set the override-redirect window attribute to true if you want to bypass
3609    /// this mechanism.
3610    ///
3611    /// If the window manager decides to map the window (or if no window manager is
3612    /// running), a MapNotify event is generated.
3613    ///
3614    /// If the window becomes viewable and no earlier contents for it are remembered,
3615    /// the X server tiles the window with its background. If the window's background
3616    /// is undefined, the existing screen contents are not altered, and the X server
3617    /// generates zero or more Expose events.
3618    ///
3619    /// If the window type is InputOutput, an Expose event will be generated when the
3620    /// window becomes visible. The normal response to an Expose event should be to
3621    /// repaint the window.
3622    ///
3623    /// # Fields
3624    ///
3625    /// * `window` - The window to make visible.
3626    ///
3627    /// # Errors
3628    ///
3629    /// * `Match` - The specified window does not exist.
3630    ///
3631    /// # See
3632    ///
3633    /// * `MapNotify`: event
3634    /// * `Expose`: event
3635    /// * `UnmapWindow`: request
3636    fn map_window(&self, window: Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
3637    {
3638        map_window(self, window)
3639    }
3640    fn map_subwindows(&self, window: Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
3641    {
3642        map_subwindows(self, window)
3643    }
3644    /// Makes a window invisible.
3645    ///
3646    /// Unmaps the specified window. This means making the window invisible (and all
3647    /// its child windows).
3648    ///
3649    /// Unmapping a window leads to the `UnmapNotify` event being generated. Also,
3650    /// `Expose` events are generated for formerly obscured windows.
3651    ///
3652    /// # Fields
3653    ///
3654    /// * `window` - The window to make invisible.
3655    ///
3656    /// # Errors
3657    ///
3658    /// * `Window` - The specified window does not exist.
3659    ///
3660    /// # See
3661    ///
3662    /// * `UnmapNotify`: event
3663    /// * `Expose`: event
3664    /// * `MapWindow`: request
3665    fn unmap_window(&self, window: Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
3666    {
3667        unmap_window(self, window)
3668    }
3669    fn unmap_subwindows(&self, window: Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
3670    {
3671        unmap_subwindows(self, window)
3672    }
3673    /// Configures window attributes.
3674    ///
3675    /// Configures a window's size, position, border width and stacking order.
3676    ///
3677    /// # Fields
3678    ///
3679    /// * `window` - The window to configure.
3680    /// * `value_mask` - Bitmask of attributes to change.
3681    /// * `value_list` - New values, corresponding to the attributes in value_mask. The order has to
3682    /// correspond to the order of possible `value_mask` bits. See the example.
3683    ///
3684    /// # Errors
3685    ///
3686    /// * `Match` - You specified a Sibling without also specifying StackMode or the window is not
3687    /// actually a Sibling.
3688    /// * `Window` - The specified window does not exist. TODO: any other reason?
3689    /// * `Value` - TODO: reasons?
3690    ///
3691    /// # See
3692    ///
3693    /// * `MapNotify`: event
3694    /// * `Expose`: event
3695    ///
3696    /// # Example
3697    ///
3698    /// ```text
3699    /// /*
3700    ///  * Configures the given window to the left upper corner
3701    ///  * with a size of 1024x768 pixels.
3702    ///  *
3703    ///  */
3704    /// void my_example(xcb_connection_t *c, xcb_window_t window) {
3705    ///     uint16_t mask = 0;
3706    ///
3707    ///     mask |= XCB_CONFIG_WINDOW_X;
3708    ///     mask |= XCB_CONFIG_WINDOW_Y;
3709    ///     mask |= XCB_CONFIG_WINDOW_WIDTH;
3710    ///     mask |= XCB_CONFIG_WINDOW_HEIGHT;
3711    ///
3712    ///     const uint32_t values[] = {
3713    ///         0,    /* x */
3714    ///         0,    /* y */
3715    ///         1024, /* width */
3716    ///         768   /* height */
3717    ///     };
3718    ///
3719    ///     xcb_configure_window(c, window, mask, values);
3720    ///     xcb_flush(c);
3721    /// }
3722    /// ```
3723    fn configure_window<'c, 'input>(&'c self, window: Window, value_list: &'input ConfigureWindowAux) -> Result<VoidCookie<'c, Self>, ConnectionError>
3724    {
3725        configure_window(self, window, value_list)
3726    }
3727    /// Change window stacking order.
3728    ///
3729    /// If `direction` is `XCB_CIRCULATE_RAISE_LOWEST`, the lowest mapped child (if
3730    /// any) will be raised to the top of the stack.
3731    ///
3732    /// If `direction` is `XCB_CIRCULATE_LOWER_HIGHEST`, the highest mapped child will
3733    /// be lowered to the bottom of the stack.
3734    ///
3735    /// # Fields
3736    ///
3737    /// * `direction` -
3738    /// * `window` - The window to raise/lower (depending on `direction`).
3739    ///
3740    /// # Errors
3741    ///
3742    /// * `Window` - The specified `window` does not exist.
3743    /// * `Value` - The specified `direction` is invalid.
3744    fn circulate_window(&self, direction: Circulate, window: Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
3745    {
3746        circulate_window(self, direction, window)
3747    }
3748    /// Get current window geometry.
3749    ///
3750    /// Gets the current geometry of the specified drawable (either `Window` or `Pixmap`).
3751    ///
3752    /// # Fields
3753    ///
3754    /// * `drawable` - The drawable (`Window` or `Pixmap`) of which the geometry will be received.
3755    ///
3756    /// # Errors
3757    ///
3758    /// * `Drawable` - TODO: reasons?
3759    /// * `Window` - TODO: reasons?
3760    ///
3761    /// # See
3762    ///
3763    /// * `xwininfo`: program
3764    ///
3765    /// # Example
3766    ///
3767    /// ```text
3768    /// /*
3769    ///  * Displays the x and y position of the given window.
3770    ///  *
3771    ///  */
3772    /// void my_example(xcb_connection_t *c, xcb_window_t window) {
3773    ///     xcb_get_geometry_cookie_t cookie;
3774    ///     xcb_get_geometry_reply_t *reply;
3775    ///
3776    ///     cookie = xcb_get_geometry(c, window);
3777    ///     /* ... do other work here if possible ... */
3778    ///     if ((reply = xcb_get_geometry_reply(c, cookie, NULL))) {
3779    ///         printf("This window is at %d, %d\\n", reply->x, reply->y);
3780    ///     }
3781    ///     free(reply);
3782    /// }
3783    /// ```
3784    fn get_geometry(&self, drawable: Drawable) -> Result<Cookie<'_, Self, GetGeometryReply>, ConnectionError>
3785    {
3786        get_geometry(self, drawable)
3787    }
3788    /// query the window tree.
3789    ///
3790    /// Gets the root window ID, parent window ID and list of children windows for the
3791    /// specified `window`. The children are listed in bottom-to-top stacking order.
3792    ///
3793    /// # Fields
3794    ///
3795    /// * `window` - The `window` to query.
3796    ///
3797    /// # See
3798    ///
3799    /// * `xwininfo`: program
3800    ///
3801    /// # Example
3802    ///
3803    /// ```text
3804    /// /*
3805    ///  * Displays the root, parent and children of the specified window.
3806    ///  *
3807    ///  */
3808    /// void my_example(xcb_connection_t *conn, xcb_window_t window) {
3809    ///     xcb_query_tree_cookie_t cookie;
3810    ///     xcb_query_tree_reply_t *reply;
3811    ///
3812    ///     cookie = xcb_query_tree(conn, window);
3813    ///     if ((reply = xcb_query_tree_reply(conn, cookie, NULL))) {
3814    ///         printf("root = 0x%08x\\n", reply->root);
3815    ///         printf("parent = 0x%08x\\n", reply->parent);
3816    ///
3817    ///         xcb_window_t *children = xcb_query_tree_children(reply);
3818    ///         for (int i = 0; i < xcb_query_tree_children_length(reply); i++)
3819    ///             printf("child window = 0x%08x\\n", children[i]);
3820    ///
3821    ///         free(reply);
3822    ///     }
3823    /// }
3824    /// ```
3825    fn query_tree(&self, window: Window) -> Result<Cookie<'_, Self, QueryTreeReply>, ConnectionError>
3826    {
3827        query_tree(self, window)
3828    }
3829    /// Get atom identifier by name.
3830    ///
3831    /// Retrieves the identifier (xcb_atom_t TODO) for the atom with the specified
3832    /// name. Atoms are used in protocols like EWMH, for example to store window titles
3833    /// (`_NET_WM_NAME` atom) as property of a window.
3834    ///
3835    /// If `only_if_exists` is 0, the atom will be created if it does not already exist.
3836    /// If `only_if_exists` is 1, `XCB_ATOM_NONE` will be returned if the atom does
3837    /// not yet exist.
3838    ///
3839    /// # Fields
3840    ///
3841    /// * `name_len` - The length of the following `name`.
3842    /// * `name` - The name of the atom.
3843    /// * `only_if_exists` - Return a valid atom id only if the atom already exists.
3844    ///
3845    /// # Errors
3846    ///
3847    /// * `Alloc` - TODO: reasons?
3848    /// * `Value` - A value other than 0 or 1 was specified for `only_if_exists`.
3849    ///
3850    /// # See
3851    ///
3852    /// * `xlsatoms`: program
3853    /// * `GetAtomName`: request
3854    ///
3855    /// # Example
3856    ///
3857    /// ```text
3858    /// /*
3859    ///  * Resolves the _NET_WM_NAME atom.
3860    ///  *
3861    ///  */
3862    /// void my_example(xcb_connection_t *c) {
3863    ///     xcb_intern_atom_cookie_t cookie;
3864    ///     xcb_intern_atom_reply_t *reply;
3865    ///
3866    ///     cookie = xcb_intern_atom(c, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME");
3867    ///     /* ... do other work here if possible ... */
3868    ///     if ((reply = xcb_intern_atom_reply(c, cookie, NULL))) {
3869    ///         printf("The _NET_WM_NAME atom has ID %u\n", reply->atom);
3870    ///         free(reply);
3871    ///     }
3872    /// }
3873    /// ```
3874    fn intern_atom<'c, 'input>(&'c self, only_if_exists: bool, name: &'input [u8]) -> Result<Cookie<'c, Self, InternAtomReply>, ConnectionError>
3875    {
3876        intern_atom(self, only_if_exists, name)
3877    }
3878    fn get_atom_name(&self, atom: Atom) -> Result<Cookie<'_, Self, GetAtomNameReply>, ConnectionError>
3879    {
3880        get_atom_name(self, atom)
3881    }
3882    /// Changes a window property.
3883    ///
3884    /// Sets or updates a property on the specified `window`. Properties are for
3885    /// example the window title (`WM_NAME`) or its minimum size (`WM_NORMAL_HINTS`).
3886    /// Protocols such as EWMH also use properties - for example EWMH defines the
3887    /// window title, encoded as UTF-8 string, in the `_NET_WM_NAME` property.
3888    ///
3889    /// # Fields
3890    ///
3891    /// * `window` - The window whose property you want to change.
3892    /// * `mode` -
3893    /// * `property` - The property you want to change (an atom).
3894    /// * `type` - The type of the property you want to change (an atom).
3895    /// * `format` - Specifies whether the data should be viewed as a list of 8-bit, 16-bit or
3896    /// 32-bit quantities. Possible values are 8, 16 and 32. This information allows
3897    /// the X server to correctly perform byte-swap operations as necessary.
3898    /// * `data_len` - Specifies the number of elements (see `format`).
3899    /// * `data` - The property data.
3900    ///
3901    /// # Errors
3902    ///
3903    /// * `Match` - TODO: reasons?
3904    /// * `Value` - TODO: reasons?
3905    /// * `Window` - The specified `window` does not exist.
3906    /// * `Atom` - `property` or `type` do not refer to a valid atom.
3907    /// * `Alloc` - The X server could not store the property (no memory?).
3908    ///
3909    /// # See
3910    ///
3911    /// * `InternAtom`: request
3912    /// * `xprop`: program
3913    ///
3914    /// # Example
3915    ///
3916    /// ```text
3917    /// /*
3918    ///  * Sets the WM_NAME property of the window to "XCB Example".
3919    ///  *
3920    ///  */
3921    /// void my_example(xcb_connection_t *conn, xcb_window_t window) {
3922    ///     xcb_change_property(conn,
3923    ///         XCB_PROP_MODE_REPLACE,
3924    ///         window,
3925    ///         XCB_ATOM_WM_NAME,
3926    ///         XCB_ATOM_STRING,
3927    ///         8,
3928    ///         strlen("XCB Example"),
3929    ///         "XCB Example");
3930    ///     xcb_flush(conn);
3931    /// }
3932    /// ```
3933    fn change_property<'c, 'input, A, B>(&'c self, mode: PropMode, window: Window, property: A, type_: B, format: u8, data_len: u32, data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
3934    where
3935        A: Into<Atom>,
3936        B: Into<Atom>,
3937    {
3938        change_property(self, mode, window, property, type_, format, data_len, data)
3939    }
3940    fn delete_property(&self, window: Window, property: Atom) -> Result<VoidCookie<'_, Self>, ConnectionError>
3941    {
3942        delete_property(self, window, property)
3943    }
3944    /// Gets a window property.
3945    ///
3946    /// Gets the specified `property` from the specified `window`. Properties are for
3947    /// example the window title (`WM_NAME`) or its minimum size (`WM_NORMAL_HINTS`).
3948    /// Protocols such as EWMH also use properties - for example EWMH defines the
3949    /// window title, encoded as UTF-8 string, in the `_NET_WM_NAME` property.
3950    ///
3951    /// TODO: talk about `type`
3952    ///
3953    /// TODO: talk about `delete`
3954    ///
3955    /// TODO: talk about the offset/length thing. what's a valid use case?
3956    ///
3957    /// # Fields
3958    ///
3959    /// * `window` - The window whose property you want to get.
3960    /// * `delete` - Whether the property should actually be deleted. For deleting a property, the
3961    /// specified `type` has to match the actual property type.
3962    /// * `property` - The property you want to get (an atom).
3963    /// * `type` - The type of the property you want to get (an atom).
3964    /// * `long_offset` - Specifies the offset (in 32-bit multiples) in the specified property where the
3965    /// data is to be retrieved.
3966    /// * `long_length` - Specifies how many 32-bit multiples of data should be retrieved (e.g. if you
3967    /// set `long_length` to 4, you will receive 16 bytes of data).
3968    ///
3969    /// # Errors
3970    ///
3971    /// * `Window` - The specified `window` does not exist.
3972    /// * `Atom` - `property` or `type` do not refer to a valid atom.
3973    /// * `Value` - The specified `long_offset` is beyond the actual property length (e.g. the
3974    /// property has a length of 3 bytes and you are setting `long_offset` to 1,
3975    /// resulting in a byte offset of 4).
3976    ///
3977    /// # See
3978    ///
3979    /// * `InternAtom`: request
3980    /// * `xprop`: program
3981    ///
3982    /// # Example
3983    ///
3984    /// ```text
3985    /// /*
3986    ///  * Prints the WM_NAME property of the window.
3987    ///  *
3988    ///  */
3989    /// void my_example(xcb_connection_t *c, xcb_window_t window) {
3990    ///     xcb_get_property_cookie_t cookie;
3991    ///     xcb_get_property_reply_t *reply;
3992    ///
3993    ///     /* These atoms are predefined in the X11 protocol. */
3994    ///     xcb_atom_t property = XCB_ATOM_WM_NAME;
3995    ///     xcb_atom_t type = XCB_ATOM_STRING;
3996    ///
3997    ///     // TODO: a reasonable long_length for WM_NAME?
3998    ///     cookie = xcb_get_property(c, 0, window, property, type, 0, 0);
3999    ///     if ((reply = xcb_get_property_reply(c, cookie, NULL))) {
4000    ///         int len = xcb_get_property_value_length(reply);
4001    ///         if (len == 0) {
4002    ///             printf("TODO\\n");
4003    ///             free(reply);
4004    ///             return;
4005    ///         }
4006    ///         printf("WM_NAME is %.*s\\n", len,
4007    ///                (char*)xcb_get_property_value(reply));
4008    ///     }
4009    ///     free(reply);
4010    /// }
4011    /// ```
4012    fn get_property<A, B>(&self, delete: bool, window: Window, property: A, type_: B, long_offset: u32, long_length: u32) -> Result<Cookie<'_, Self, GetPropertyReply>, ConnectionError>
4013    where
4014        A: Into<Atom>,
4015        B: Into<Atom>,
4016    {
4017        get_property(self, delete, window, property, type_, long_offset, long_length)
4018    }
4019    fn list_properties(&self, window: Window) -> Result<Cookie<'_, Self, ListPropertiesReply>, ConnectionError>
4020    {
4021        list_properties(self, window)
4022    }
4023    /// Sets the owner of a selection.
4024    ///
4025    /// Makes `window` the owner of the selection `selection` and updates the
4026    /// last-change time of the specified selection.
4027    ///
4028    /// TODO: briefly explain what a selection is.
4029    ///
4030    /// # Fields
4031    ///
4032    /// * `selection` - The selection.
4033    /// * `owner` - The new owner of the selection.
4034    ///
4035    /// The special value `XCB_NONE` means that the selection will have no owner.
4036    /// * `time` - Timestamp to avoid race conditions when running X over the network.
4037    ///
4038    /// The selection will not be changed if `time` is earlier than the current
4039    /// last-change time of the `selection` or is later than the current X server time.
4040    /// Otherwise, the last-change time is set to the specified time.
4041    ///
4042    /// The special value `XCB_CURRENT_TIME` will be replaced with the current server
4043    /// time.
4044    ///
4045    /// # Errors
4046    ///
4047    /// * `Atom` - `selection` does not refer to a valid atom.
4048    ///
4049    /// # See
4050    ///
4051    /// * `SetSelectionOwner`: request
4052    fn set_selection_owner<A, B>(&self, owner: A, selection: Atom, time: B) -> Result<VoidCookie<'_, Self>, ConnectionError>
4053    where
4054        A: Into<Window>,
4055        B: Into<Timestamp>,
4056    {
4057        set_selection_owner(self, owner, selection, time)
4058    }
4059    /// Gets the owner of a selection.
4060    ///
4061    /// Gets the owner of the specified selection.
4062    ///
4063    /// TODO: briefly explain what a selection is.
4064    ///
4065    /// # Fields
4066    ///
4067    /// * `selection` - The selection.
4068    ///
4069    /// # Errors
4070    ///
4071    /// * `Atom` - `selection` does not refer to a valid atom.
4072    ///
4073    /// # See
4074    ///
4075    /// * `SetSelectionOwner`: request
4076    fn get_selection_owner(&self, selection: Atom) -> Result<Cookie<'_, Self, GetSelectionOwnerReply>, ConnectionError>
4077    {
4078        get_selection_owner(self, selection)
4079    }
4080    fn convert_selection<A, B>(&self, requestor: Window, selection: Atom, target: Atom, property: A, time: B) -> Result<VoidCookie<'_, Self>, ConnectionError>
4081    where
4082        A: Into<Atom>,
4083        B: Into<Timestamp>,
4084    {
4085        convert_selection(self, requestor, selection, target, property, time)
4086    }
4087    /// send an event.
4088    ///
4089    /// Identifies the `destination` window, determines which clients should receive
4090    /// the specified event and ignores any active grabs.
4091    ///
4092    /// The `event` must be one of the core events or an event defined by an extension,
4093    /// so that the X server can correctly byte-swap the contents as necessary. The
4094    /// contents of `event` are otherwise unaltered and unchecked except for the
4095    /// `send_event` field which is forced to 'true'.
4096    ///
4097    /// # Fields
4098    ///
4099    /// * `destination` - The window to send this event to. Every client which selects any event within
4100    /// `event_mask` on `destination` will get the event.
4101    ///
4102    /// The special value `XCB_SEND_EVENT_DEST_POINTER_WINDOW` refers to the window
4103    /// that contains the mouse pointer.
4104    ///
4105    /// The special value `XCB_SEND_EVENT_DEST_ITEM_FOCUS` refers to the window which
4106    /// has the keyboard focus.
4107    /// * `event_mask` - Event_mask for determining which clients should receive the specified event.
4108    /// See `destination` and `propagate`.
4109    /// * `propagate` - If `propagate` is true and no clients have selected any event on `destination`,
4110    /// the destination is replaced with the closest ancestor of `destination` for
4111    /// which some client has selected a type in `event_mask` and for which no
4112    /// intervening window has that type in its do-not-propagate-mask. If no such
4113    /// window exists or if the window is an ancestor of the focus window and
4114    /// `InputFocus` was originally specified as the destination, the event is not sent
4115    /// to any clients. Otherwise, the event is reported to every client selecting on
4116    /// the final destination any of the types specified in `event_mask`.
4117    /// * `event` - The event to send to the specified `destination`.
4118    ///
4119    /// # Errors
4120    ///
4121    /// * `Window` - The specified `destination` window does not exist.
4122    /// * `Value` - The given `event` is neither a core event nor an event defined by an extension.
4123    ///
4124    /// # See
4125    ///
4126    /// * `ConfigureNotify`: event
4127    ///
4128    /// # Example
4129    ///
4130    /// ```text
4131    /// /*
4132    ///  * Tell the given window that it was configured to a size of 800x600 pixels.
4133    ///  *
4134    ///  */
4135    /// void my_example(xcb_connection_t *conn, xcb_window_t window) {
4136    ///     /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
4137    ///      * In order to properly initialize these bytes, we allocate 32 bytes even
4138    ///      * though we only need less for an xcb_configure_notify_event_t */
4139    ///     xcb_configure_notify_event_t *event = calloc(32, 1);
4140    ///
4141    ///     event->event = window;
4142    ///     event->window = window;
4143    ///     event->response_type = XCB_CONFIGURE_NOTIFY;
4144    ///
4145    ///     event->x = 0;
4146    ///     event->y = 0;
4147    ///     event->width = 800;
4148    ///     event->height = 600;
4149    ///
4150    ///     event->border_width = 0;
4151    ///     event->above_sibling = XCB_NONE;
4152    ///     event->override_redirect = false;
4153    ///
4154    ///     xcb_send_event(conn, false, window, XCB_EVENT_MASK_STRUCTURE_NOTIFY,
4155    ///                    (char*)event);
4156    ///     xcb_flush(conn);
4157    ///     free(event);
4158    /// }
4159    /// ```
4160    fn send_event<A, B>(&self, propagate: bool, destination: A, event_mask: EventMask, event: B) -> Result<VoidCookie<'_, Self>, ConnectionError>
4161    where
4162        A: Into<Window>,
4163        B: Into<[u8; 32]>,
4164    {
4165        send_event(self, propagate, destination, event_mask, event)
4166    }
4167    /// Grab the pointer.
4168    ///
4169    /// Actively grabs control of the pointer. Further pointer events are reported only to the grabbing client. Overrides any active pointer grab by this client.
4170    ///
4171    /// # Fields
4172    ///
4173    /// * `event_mask` - Specifies which pointer events are reported to the client.
4174    ///
4175    /// TODO: which values?
4176    /// * `confine_to` - Specifies the window to confine the pointer in (the user will not be able to
4177    /// move the pointer out of that window).
4178    ///
4179    /// The special value `XCB_NONE` means don't confine the pointer.
4180    /// * `cursor` - Specifies the cursor that should be displayed or `XCB_NONE` to not change the
4181    /// cursor.
4182    /// * `owner_events` - If 1, the `grab_window` will still get the pointer events. If 0, events are not
4183    /// reported to the `grab_window`.
4184    /// * `grab_window` - Specifies the window on which the pointer should be grabbed.
4185    /// * `time` - The time argument allows you to avoid certain circumstances that come up if
4186    /// applications take a long time to respond or if there are long network delays.
4187    /// Consider a situation where you have two applications, both of which normally
4188    /// grab the pointer when clicked on. If both applications specify the timestamp
4189    /// from the event, the second application may wake up faster and successfully grab
4190    /// the pointer before the first application. The first application then will get
4191    /// an indication that the other application grabbed the pointer before its request
4192    /// was processed.
4193    ///
4194    /// The special value `XCB_CURRENT_TIME` will be replaced with the current server
4195    /// time.
4196    /// * `pointer_mode` -
4197    /// * `keyboard_mode` -
4198    ///
4199    /// # Errors
4200    ///
4201    /// * `Value` - TODO: reasons?
4202    /// * `Window` - The specified `window` does not exist.
4203    ///
4204    /// # See
4205    ///
4206    /// * `GrabKeyboard`: request
4207    ///
4208    /// # Example
4209    ///
4210    /// ```text
4211    /// /*
4212    ///  * Grabs the pointer actively
4213    ///  *
4214    ///  */
4215    /// void my_example(xcb_connection_t *conn, xcb_screen_t *screen, xcb_cursor_t cursor) {
4216    ///     xcb_grab_pointer_cookie_t cookie;
4217    ///     xcb_grab_pointer_reply_t *reply;
4218    ///
4219    ///     cookie = xcb_grab_pointer(
4220    ///         conn,
4221    ///         false,               /* get all pointer events specified by the following mask */
4222    ///         screen->root,        /* grab the root window */
4223    ///         XCB_NONE,            /* which events to let through */
4224    ///         XCB_GRAB_MODE_ASYNC, /* pointer events should continue as normal */
4225    ///         XCB_GRAB_MODE_ASYNC, /* keyboard mode */
4226    ///         XCB_NONE,            /* confine_to = in which window should the cursor stay */
4227    ///         cursor,              /* we change the cursor to whatever the user wanted */
4228    ///         XCB_CURRENT_TIME
4229    ///     );
4230    ///
4231    ///     if ((reply = xcb_grab_pointer_reply(conn, cookie, NULL))) {
4232    ///         if (reply->status == XCB_GRAB_STATUS_SUCCESS)
4233    ///             printf("successfully grabbed the pointer\\n");
4234    ///         free(reply);
4235    ///     }
4236    /// }
4237    /// ```
4238    fn grab_pointer<A, B, C>(&self, owner_events: bool, grab_window: Window, event_mask: EventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, time: C) -> Result<Cookie<'_, Self, GrabPointerReply>, ConnectionError>
4239    where
4240        A: Into<Window>,
4241        B: Into<Cursor>,
4242        C: Into<Timestamp>,
4243    {
4244        grab_pointer(self, owner_events, grab_window, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, time)
4245    }
4246    /// release the pointer.
4247    ///
4248    /// Releases the pointer and any queued events if you actively grabbed the pointer
4249    /// before using `xcb_grab_pointer`, `xcb_grab_button` or within a normal button
4250    /// press.
4251    ///
4252    /// EnterNotify and LeaveNotify events are generated.
4253    ///
4254    /// # Fields
4255    ///
4256    /// * `time` - Timestamp to avoid race conditions when running X over the network.
4257    ///
4258    /// The pointer will not be released if `time` is earlier than the
4259    /// last-pointer-grab time or later than the current X server time.
4260    /// * `name_len` - Length (in bytes) of `name`.
4261    /// * `name` - A pattern describing an X core font.
4262    ///
4263    /// # See
4264    ///
4265    /// * `GrabPointer`: request
4266    /// * `GrabButton`: request
4267    /// * `EnterNotify`: event
4268    /// * `LeaveNotify`: event
4269    fn ungrab_pointer<A>(&self, time: A) -> Result<VoidCookie<'_, Self>, ConnectionError>
4270    where
4271        A: Into<Timestamp>,
4272    {
4273        ungrab_pointer(self, time)
4274    }
4275    /// Grab pointer button(s).
4276    ///
4277    /// This request establishes a passive grab. The pointer is actively grabbed as
4278    /// described in GrabPointer, the last-pointer-grab time is set to the time at
4279    /// which the button was pressed (as transmitted in the ButtonPress event), and the
4280    /// ButtonPress event is reported if all of the following conditions are true:
4281    ///
4282    /// The pointer is not grabbed and the specified button is logically pressed when
4283    /// the specified modifier keys are logically down, and no other buttons or
4284    /// modifier keys are logically down.
4285    ///
4286    /// The grab-window contains the pointer.
4287    ///
4288    /// The confine-to window (if any) is viewable.
4289    ///
4290    /// A passive grab on the same button/key combination does not exist on any
4291    /// ancestor of grab-window.
4292    ///
4293    /// The interpretation of the remaining arguments is the same as for GrabPointer.
4294    /// The active grab is terminated automatically when the logical state of the
4295    /// pointer has all buttons released, independent of the logical state of modifier
4296    /// keys. Note that the logical state of a device (as seen by means of the
4297    /// protocol) may lag the physical state if device event processing is frozen. This
4298    /// request overrides all previous passive grabs by the same client on the same
4299    /// button/key combinations on the same window. A modifier of AnyModifier is
4300    /// equivalent to issuing the request for all possible modifier combinations
4301    /// (including the combination of no modifiers). It is not required that all
4302    /// specified modifiers have currently assigned keycodes. A button of AnyButton is
4303    /// equivalent to issuing the request for all possible buttons. Otherwise, it is
4304    /// not required that the button specified currently be assigned to a physical
4305    /// button.
4306    ///
4307    /// An Access error is generated if some other client has already issued a
4308    /// GrabButton request with the same button/key combination on the same window.
4309    /// When using AnyModifier or AnyButton, the request fails completely (no grabs are
4310    /// established), and an Access error is generated if there is a conflicting grab
4311    /// for any combination. The request has no effect on an active grab.
4312    ///
4313    /// # Fields
4314    ///
4315    /// * `owner_events` - If 1, the `grab_window` will still get the pointer events. If 0, events are not
4316    /// reported to the `grab_window`.
4317    /// * `grab_window` - Specifies the window on which the pointer should be grabbed.
4318    /// * `event_mask` - Specifies which pointer events are reported to the client.
4319    ///
4320    /// TODO: which values?
4321    /// * `confine_to` - Specifies the window to confine the pointer in (the user will not be able to
4322    /// move the pointer out of that window).
4323    ///
4324    /// The special value `XCB_NONE` means don't confine the pointer.
4325    /// * `cursor` - Specifies the cursor that should be displayed or `XCB_NONE` to not change the
4326    /// cursor.
4327    /// * `modifiers` - The modifiers to grab.
4328    ///
4329    /// Using the special value `XCB_MOD_MASK_ANY` means grab the pointer with all
4330    /// possible modifier combinations.
4331    /// * `pointer_mode` -
4332    /// * `keyboard_mode` -
4333    /// * `button` -
4334    ///
4335    /// # Errors
4336    ///
4337    /// * `Access` - Another client has already issued a GrabButton with the same button/key
4338    /// combination on the same window.
4339    /// * `Value` - TODO: reasons?
4340    /// * `Cursor` - The specified `cursor` does not exist.
4341    /// * `Window` - The specified `window` does not exist.
4342    fn grab_button<A, B>(&self, owner_events: bool, grab_window: Window, event_mask: EventMask, pointer_mode: GrabMode, keyboard_mode: GrabMode, confine_to: A, cursor: B, button: ButtonIndex, modifiers: ModMask) -> Result<VoidCookie<'_, Self>, ConnectionError>
4343    where
4344        A: Into<Window>,
4345        B: Into<Cursor>,
4346    {
4347        grab_button(self, owner_events, grab_window, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, button, modifiers)
4348    }
4349    fn ungrab_button(&self, button: ButtonIndex, grab_window: Window, modifiers: ModMask) -> Result<VoidCookie<'_, Self>, ConnectionError>
4350    {
4351        ungrab_button(self, button, grab_window, modifiers)
4352    }
4353    fn change_active_pointer_grab<A, B>(&self, cursor: A, time: B, event_mask: EventMask) -> Result<VoidCookie<'_, Self>, ConnectionError>
4354    where
4355        A: Into<Cursor>,
4356        B: Into<Timestamp>,
4357    {
4358        change_active_pointer_grab(self, cursor, time, event_mask)
4359    }
4360    /// Grab the keyboard.
4361    ///
4362    /// Actively grabs control of the keyboard and generates FocusIn and FocusOut
4363    /// events. Further key events are reported only to the grabbing client.
4364    ///
4365    /// Any active keyboard grab by this client is overridden. If the keyboard is
4366    /// actively grabbed by some other client, `AlreadyGrabbed` is returned. If
4367    /// `grab_window` is not viewable, `GrabNotViewable` is returned. If the keyboard
4368    /// is frozen by an active grab of another client, `GrabFrozen` is returned. If the
4369    /// specified `time` is earlier than the last-keyboard-grab time or later than the
4370    /// current X server time, `GrabInvalidTime` is returned. Otherwise, the
4371    /// last-keyboard-grab time is set to the specified time.
4372    ///
4373    /// # Fields
4374    ///
4375    /// * `owner_events` - If 1, the `grab_window` will still get the pointer events. If 0, events are not
4376    /// reported to the `grab_window`.
4377    /// * `grab_window` - Specifies the window on which the pointer should be grabbed.
4378    /// * `time` - Timestamp to avoid race conditions when running X over the network.
4379    ///
4380    /// The special value `XCB_CURRENT_TIME` will be replaced with the current server
4381    /// time.
4382    /// * `pointer_mode` -
4383    /// * `keyboard_mode` -
4384    ///
4385    /// # Errors
4386    ///
4387    /// * `Value` - TODO: reasons?
4388    /// * `Window` - The specified `window` does not exist.
4389    ///
4390    /// # See
4391    ///
4392    /// * `GrabPointer`: request
4393    ///
4394    /// # Example
4395    ///
4396    /// ```text
4397    /// /*
4398    ///  * Grabs the keyboard actively
4399    ///  *
4400    ///  */
4401    /// void my_example(xcb_connection_t *conn, xcb_screen_t *screen) {
4402    ///     xcb_grab_keyboard_cookie_t cookie;
4403    ///     xcb_grab_keyboard_reply_t *reply;
4404    ///
4405    ///     cookie = xcb_grab_keyboard(
4406    ///         conn,
4407    ///         true,                /* report events */
4408    ///         screen->root,        /* grab the root window */
4409    ///         XCB_CURRENT_TIME,
4410    ///         XCB_GRAB_MODE_ASYNC, /* process events as normal, do not require sync */
4411    ///         XCB_GRAB_MODE_ASYNC
4412    ///     );
4413    ///
4414    ///     if ((reply = xcb_grab_keyboard_reply(conn, cookie, NULL))) {
4415    ///         if (reply->status == XCB_GRAB_STATUS_SUCCESS)
4416    ///             printf("successfully grabbed the keyboard\\n");
4417    ///
4418    ///         free(reply);
4419    ///     }
4420    /// }
4421    /// ```
4422    fn grab_keyboard<A>(&self, owner_events: bool, grab_window: Window, time: A, pointer_mode: GrabMode, keyboard_mode: GrabMode) -> Result<Cookie<'_, Self, GrabKeyboardReply>, ConnectionError>
4423    where
4424        A: Into<Timestamp>,
4425    {
4426        grab_keyboard(self, owner_events, grab_window, time, pointer_mode, keyboard_mode)
4427    }
4428    fn ungrab_keyboard<A>(&self, time: A) -> Result<VoidCookie<'_, Self>, ConnectionError>
4429    where
4430        A: Into<Timestamp>,
4431    {
4432        ungrab_keyboard(self, time)
4433    }
4434    /// Grab keyboard key(s).
4435    ///
4436    /// Establishes a passive grab on the keyboard. In the future, the keyboard is
4437    /// actively grabbed (as for `GrabKeyboard`), the last-keyboard-grab time is set to
4438    /// the time at which the key was pressed (as transmitted in the KeyPress event),
4439    /// and the KeyPress event is reported if all of the following conditions are true:
4440    ///
4441    /// The keyboard is not grabbed and the specified key (which can itself be a
4442    /// modifier key) is logically pressed when the specified modifier keys are
4443    /// logically down, and no other modifier keys are logically down.
4444    ///
4445    /// Either the grab_window is an ancestor of (or is) the focus window, or the
4446    /// grab_window is a descendant of the focus window and contains the pointer.
4447    ///
4448    /// A passive grab on the same key combination does not exist on any ancestor of
4449    /// grab_window.
4450    ///
4451    /// The interpretation of the remaining arguments is as for XGrabKeyboard.  The active grab is terminated
4452    /// automatically when the logical state of the keyboard has the specified key released (independent of the
4453    /// logical state of the modifier keys), at which point a KeyRelease event is reported to the grabbing window.
4454    ///
4455    /// Note that the logical state of a device (as seen by client applications) may lag the physical state if
4456    /// device event processing is frozen.
4457    ///
4458    /// A modifiers argument of AnyModifier is equivalent to issuing the request for all possible modifier combinations (including the combination of no modifiers).  It is not required that all modifiers specified
4459    /// have currently assigned KeyCodes.  A keycode argument of AnyKey is equivalent to issuing the request for
4460    /// all possible KeyCodes.  Otherwise, the specified keycode must be in the range specified by min_keycode
4461    /// and max_keycode in the connection setup, or a BadValue error results.
4462    ///
4463    /// If some other client has issued a XGrabKey with the same key combination on the same window, a BadAccess
4464    /// error results.  When using AnyModifier or AnyKey, the request fails completely, and a BadAccess error
4465    /// results (no grabs are established) if there is a conflicting grab for any combination.
4466    ///
4467    /// # Fields
4468    ///
4469    /// * `owner_events` - If 1, the `grab_window` will still get the key events. If 0, events are not
4470    /// reported to the `grab_window`.
4471    /// * `grab_window` - Specifies the window on which the key should be grabbed.
4472    /// * `key` - The keycode of the key to grab.
4473    ///
4474    /// The special value `XCB_GRAB_ANY` means grab any key.
4475    /// * `modifiers` - The modifiers to grab.
4476    ///
4477    /// Using the special value `XCB_MOD_MASK_ANY` means grab the key with all
4478    /// possible modifier combinations.
4479    /// * `pointer_mode` -
4480    /// * `keyboard_mode` -
4481    ///
4482    /// # Errors
4483    ///
4484    /// * `Access` - Another client has already issued a GrabKey with the same button/key
4485    /// combination on the same window.
4486    /// * `Value` - The key is not `XCB_GRAB_ANY` and not in the range specified by `min_keycode`
4487    /// and `max_keycode` in the connection setup.
4488    /// * `Window` - The specified `window` does not exist.
4489    ///
4490    /// # See
4491    ///
4492    /// * `GrabKeyboard`: request
4493    fn grab_key<A>(&self, owner_events: bool, grab_window: Window, modifiers: ModMask, key: A, pointer_mode: GrabMode, keyboard_mode: GrabMode) -> Result<VoidCookie<'_, Self>, ConnectionError>
4494    where
4495        A: Into<Keycode>,
4496    {
4497        grab_key(self, owner_events, grab_window, modifiers, key, pointer_mode, keyboard_mode)
4498    }
4499    /// release a key combination.
4500    ///
4501    /// Releases the key combination on `grab_window` if you grabbed it using
4502    /// `xcb_grab_key` before.
4503    ///
4504    /// # Fields
4505    ///
4506    /// * `key` - The keycode of the specified key combination.
4507    ///
4508    /// Using the special value `XCB_GRAB_ANY` means releasing all possible key codes.
4509    /// * `grab_window` - The window on which the grabbed key combination will be released.
4510    /// * `modifiers` - The modifiers of the specified key combination.
4511    ///
4512    /// Using the special value `XCB_MOD_MASK_ANY` means releasing the key combination
4513    /// with every possible modifier combination.
4514    ///
4515    /// # Errors
4516    ///
4517    /// * `Window` - The specified `grab_window` does not exist.
4518    /// * `Value` - TODO: reasons?
4519    ///
4520    /// # See
4521    ///
4522    /// * `GrabKey`: request
4523    /// * `xev`: program
4524    fn ungrab_key<A>(&self, key: A, grab_window: Window, modifiers: ModMask) -> Result<VoidCookie<'_, Self>, ConnectionError>
4525    where
4526        A: Into<Keycode>,
4527    {
4528        ungrab_key(self, key, grab_window, modifiers)
4529    }
4530    /// release queued events.
4531    ///
4532    /// Releases queued events if the client has caused a device (pointer/keyboard) to
4533    /// freeze due to grabbing it actively. This request has no effect if `time` is
4534    /// earlier than the last-grab time of the most recent active grab for this client
4535    /// or if `time` is later than the current X server time.
4536    ///
4537    /// # Fields
4538    ///
4539    /// * `mode` -
4540    /// * `time` - Timestamp to avoid race conditions when running X over the network.
4541    ///
4542    /// The special value `XCB_CURRENT_TIME` will be replaced with the current server
4543    /// time.
4544    ///
4545    /// # Errors
4546    ///
4547    /// * `Value` - You specified an invalid `mode`.
4548    fn allow_events<A>(&self, mode: Allow, time: A) -> Result<VoidCookie<'_, Self>, ConnectionError>
4549    where
4550        A: Into<Timestamp>,
4551    {
4552        allow_events(self, mode, time)
4553    }
4554    fn grab_server(&self) -> Result<VoidCookie<'_, Self>, ConnectionError>
4555    {
4556        grab_server(self)
4557    }
4558    fn ungrab_server(&self) -> Result<VoidCookie<'_, Self>, ConnectionError>
4559    {
4560        ungrab_server(self)
4561    }
4562    /// get pointer coordinates.
4563    ///
4564    /// Gets the root window the pointer is logically on and the pointer coordinates
4565    /// relative to the root window's origin.
4566    ///
4567    /// # Fields
4568    ///
4569    /// * `window` - A window to check if the pointer is on the same screen as `window` (see the
4570    /// `same_screen` field in the reply).
4571    ///
4572    /// # Errors
4573    ///
4574    /// * `Window` - The specified `window` does not exist.
4575    fn query_pointer(&self, window: Window) -> Result<Cookie<'_, Self, QueryPointerReply>, ConnectionError>
4576    {
4577        query_pointer(self, window)
4578    }
4579    fn get_motion_events<A, B>(&self, window: Window, start: A, stop: B) -> Result<Cookie<'_, Self, GetMotionEventsReply>, ConnectionError>
4580    where
4581        A: Into<Timestamp>,
4582        B: Into<Timestamp>,
4583    {
4584        get_motion_events(self, window, start, stop)
4585    }
4586    fn translate_coordinates(&self, src_window: Window, dst_window: Window, src_x: i16, src_y: i16) -> Result<Cookie<'_, Self, TranslateCoordinatesReply>, ConnectionError>
4587    {
4588        translate_coordinates(self, src_window, dst_window, src_x, src_y)
4589    }
4590    /// move mouse pointer.
4591    ///
4592    /// Moves the mouse pointer to the specified position.
4593    ///
4594    /// If `src_window` is not `XCB_NONE` (TODO), the move will only take place if the
4595    /// pointer is inside `src_window` and within the rectangle specified by (`src_x`,
4596    /// `src_y`, `src_width`, `src_height`). The rectangle coordinates are relative to
4597    /// `src_window`.
4598    ///
4599    /// If `dst_window` is not `XCB_NONE` (TODO), the pointer will be moved to the
4600    /// offsets (`dst_x`, `dst_y`) relative to `dst_window`. If `dst_window` is
4601    /// `XCB_NONE` (TODO), the pointer will be moved by the offsets (`dst_x`, `dst_y`)
4602    /// relative to the current position of the pointer.
4603    ///
4604    /// # Fields
4605    ///
4606    /// * `src_window` - If `src_window` is not `XCB_NONE` (TODO), the move will only take place if the
4607    /// pointer is inside `src_window` and within the rectangle specified by (`src_x`,
4608    /// `src_y`, `src_width`, `src_height`). The rectangle coordinates are relative to
4609    /// `src_window`.
4610    /// * `dst_window` - If `dst_window` is not `XCB_NONE` (TODO), the pointer will be moved to the
4611    /// offsets (`dst_x`, `dst_y`) relative to `dst_window`. If `dst_window` is
4612    /// `XCB_NONE` (TODO), the pointer will be moved by the offsets (`dst_x`, `dst_y`)
4613    /// relative to the current position of the pointer.
4614    ///
4615    /// # Errors
4616    ///
4617    /// * `Window` - TODO: reasons?
4618    ///
4619    /// # See
4620    ///
4621    /// * `SetInputFocus`: request
4622    fn warp_pointer<A, B>(&self, src_window: A, dst_window: B, src_x: i16, src_y: i16, src_width: u16, src_height: u16, dst_x: i16, dst_y: i16) -> Result<VoidCookie<'_, Self>, ConnectionError>
4623    where
4624        A: Into<Window>,
4625        B: Into<Window>,
4626    {
4627        warp_pointer(self, src_window, dst_window, src_x, src_y, src_width, src_height, dst_x, dst_y)
4628    }
4629    /// Sets input focus.
4630    ///
4631    /// Changes the input focus and the last-focus-change time. If the specified `time`
4632    /// is earlier than the current last-focus-change time, the request is ignored (to
4633    /// avoid race conditions when running X over the network).
4634    ///
4635    /// A FocusIn and FocusOut event is generated when focus is changed.
4636    ///
4637    /// # Fields
4638    ///
4639    /// * `focus` - The window to focus. All keyboard events will be reported to this window. The
4640    /// window must be viewable (TODO), or a `xcb_match_error_t` occurs (TODO).
4641    ///
4642    /// If `focus` is `XCB_NONE` (TODO), all keyboard events are
4643    /// discarded until a new focus window is set.
4644    ///
4645    /// If `focus` is `XCB_POINTER_ROOT` (TODO), focus is on the root window of the
4646    /// screen on which the pointer is on currently.
4647    /// * `time` - Timestamp to avoid race conditions when running X over the network.
4648    ///
4649    /// The special value `XCB_CURRENT_TIME` will be replaced with the current server
4650    /// time.
4651    /// * `revert_to` - Specifies what happens when the `focus` window becomes unviewable (if `focus`
4652    /// is neither `XCB_NONE` nor `XCB_POINTER_ROOT`).
4653    ///
4654    /// # Errors
4655    ///
4656    /// * `Window` - The specified `focus` window does not exist.
4657    /// * `Match` - The specified `focus` window is not viewable.
4658    /// * `Value` - TODO: Reasons?
4659    ///
4660    /// # See
4661    ///
4662    /// * `FocusIn`: event
4663    /// * `FocusOut`: event
4664    fn set_input_focus<A, B>(&self, revert_to: InputFocus, focus: A, time: B) -> Result<VoidCookie<'_, Self>, ConnectionError>
4665    where
4666        A: Into<Window>,
4667        B: Into<Timestamp>,
4668    {
4669        set_input_focus(self, revert_to, focus, time)
4670    }
4671    fn get_input_focus(&self) -> Result<Cookie<'_, Self, GetInputFocusReply>, ConnectionError>
4672    {
4673        get_input_focus(self)
4674    }
4675    fn query_keymap(&self) -> Result<Cookie<'_, Self, QueryKeymapReply>, ConnectionError>
4676    {
4677        query_keymap(self)
4678    }
4679    /// opens a font.
4680    ///
4681    /// Opens any X core font matching the given `name` (for example "-misc-fixed-*").
4682    ///
4683    /// Note that X core fonts are deprecated (but still supported) in favor of
4684    /// client-side rendering using Xft.
4685    ///
4686    /// # Fields
4687    ///
4688    /// * `fid` - The ID with which you will refer to the font, created by `xcb_generate_id`.
4689    /// * `name_len` - Length (in bytes) of `name`.
4690    /// * `name` - A pattern describing an X core font.
4691    ///
4692    /// # Errors
4693    ///
4694    /// * `Name` - No font matches the given `name`.
4695    ///
4696    /// # See
4697    ///
4698    /// * `xcb_generate_id`: function
4699    fn open_font<'c, 'input>(&'c self, fid: Font, name: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
4700    {
4701        open_font(self, fid, name)
4702    }
4703    fn close_font(&self, font: Font) -> Result<VoidCookie<'_, Self>, ConnectionError>
4704    {
4705        close_font(self, font)
4706    }
4707    /// query font metrics.
4708    ///
4709    /// Queries information associated with the font.
4710    ///
4711    /// # Fields
4712    ///
4713    /// * `font` - The fontable (Font or Graphics Context) to query.
4714    fn query_font(&self, font: Fontable) -> Result<Cookie<'_, Self, QueryFontReply>, ConnectionError>
4715    {
4716        query_font(self, font)
4717    }
4718    /// get text extents.
4719    ///
4720    /// Query text extents from the X11 server. This request returns the bounding box
4721    /// of the specified 16-bit character string in the specified `font` or the font
4722    /// contained in the specified graphics context.
4723    ///
4724    /// `font_ascent` is set to the maximum of the ascent metrics of all characters in
4725    /// the string. `font_descent` is set to the maximum of the descent metrics.
4726    /// `overall_width` is set to the sum of the character-width metrics of all
4727    /// characters in the string. For each character in the string, let W be the sum of
4728    /// the character-width metrics of all characters preceding it in the string. Let L
4729    /// be the left-side-bearing metric of the character plus W. Let R be the
4730    /// right-side-bearing metric of the character plus W. The lbearing member is set
4731    /// to the minimum L of all characters in the string. The rbearing member is set to
4732    /// the maximum R.
4733    ///
4734    /// For fonts defined with linear indexing rather than 2-byte matrix indexing, each
4735    /// `xcb_char2b_t` structure is interpreted as a 16-bit number with byte1 as the
4736    /// most significant byte. If the font has no defined default character, undefined
4737    /// characters in the string are taken to have all zero metrics.
4738    ///
4739    /// Characters with all zero metrics are ignored. If the font has no defined
4740    /// default_char, the undefined characters in the string are also ignored.
4741    ///
4742    /// # Fields
4743    ///
4744    /// * `font` - The `font` to calculate text extents in. You can also pass a graphics context.
4745    /// * `string_len` - The number of characters in `string`.
4746    /// * `string` - The text to get text extents for.
4747    ///
4748    /// # Errors
4749    ///
4750    /// * `GContext` - The specified graphics context does not exist.
4751    /// * `Font` - The specified `font` does not exist.
4752    fn query_text_extents<'c, 'input>(&'c self, font: Fontable, string: &'input [Char2b]) -> Result<Cookie<'c, Self, QueryTextExtentsReply>, ConnectionError>
4753    {
4754        query_text_extents(self, font, string)
4755    }
4756    /// get matching font names.
4757    ///
4758    /// Gets a list of available font names which match the given `pattern`.
4759    ///
4760    /// # Fields
4761    ///
4762    /// * `pattern_len` - The length (in bytes) of `pattern`.
4763    /// * `pattern` - A font pattern, for example "-misc-fixed-*".
4764    ///
4765    /// The asterisk (*) is a wildcard for any number of characters. The question mark
4766    /// (?) is a wildcard for a single character. Use of uppercase or lowercase does
4767    /// not matter.
4768    /// * `max_names` - The maximum number of fonts to be returned.
4769    fn list_fonts<'c, 'input>(&'c self, max_names: u16, pattern: &'input [u8]) -> Result<Cookie<'c, Self, ListFontsReply>, ConnectionError>
4770    {
4771        list_fonts(self, max_names, pattern)
4772    }
4773    /// get matching font names and information.
4774    ///
4775    /// Gets a list of available font names which match the given `pattern`.
4776    ///
4777    /// # Fields
4778    ///
4779    /// * `pattern_len` - The length (in bytes) of `pattern`.
4780    /// * `pattern` - A font pattern, for example "-misc-fixed-*".
4781    ///
4782    /// The asterisk (*) is a wildcard for any number of characters. The question mark
4783    /// (?) is a wildcard for a single character. Use of uppercase or lowercase does
4784    /// not matter.
4785    /// * `max_names` - The maximum number of fonts to be returned.
4786    fn list_fonts_with_info<'c, 'input>(&'c self, max_names: u16, pattern: &'input [u8]) -> Result<ListFontsWithInfoCookie<'c, Self>, ConnectionError>
4787    {
4788        list_fonts_with_info(self, max_names, pattern)
4789    }
4790    fn set_font_path<'c, 'input>(&'c self, font: &'input [Str]) -> Result<VoidCookie<'c, Self>, ConnectionError>
4791    {
4792        set_font_path(self, font)
4793    }
4794    fn get_font_path(&self) -> Result<Cookie<'_, Self, GetFontPathReply>, ConnectionError>
4795    {
4796        get_font_path(self)
4797    }
4798    /// Creates a pixmap.
4799    ///
4800    /// Creates a pixmap. The pixmap can only be used on the same screen as `drawable`
4801    /// is on and only with drawables of the same `depth`.
4802    ///
4803    /// # Fields
4804    ///
4805    /// * `depth` - TODO
4806    /// * `pid` - The ID with which you will refer to the new pixmap, created by
4807    /// `xcb_generate_id`.
4808    /// * `drawable` - Drawable to get the screen from.
4809    /// * `width` - The width of the new pixmap.
4810    /// * `height` - The height of the new pixmap.
4811    ///
4812    /// # Errors
4813    ///
4814    /// * `Value` - TODO: reasons?
4815    /// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
4816    /// * `Alloc` - The X server could not allocate the requested resources (no memory?).
4817    ///
4818    /// # See
4819    ///
4820    /// * `xcb_generate_id`: function
4821    fn create_pixmap(&self, depth: u8, pid: Pixmap, drawable: Drawable, width: u16, height: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
4822    {
4823        create_pixmap(self, depth, pid, drawable, width, height)
4824    }
4825    /// Destroys a pixmap.
4826    ///
4827    /// Deletes the association between the pixmap ID and the pixmap. The pixmap
4828    /// storage will be freed when there are no more references to it.
4829    ///
4830    /// # Fields
4831    ///
4832    /// * `pixmap` - The pixmap to destroy.
4833    ///
4834    /// # Errors
4835    ///
4836    /// * `Pixmap` - The specified pixmap does not exist.
4837    fn free_pixmap(&self, pixmap: Pixmap) -> Result<VoidCookie<'_, Self>, ConnectionError>
4838    {
4839        free_pixmap(self, pixmap)
4840    }
4841    /// Creates a graphics context.
4842    ///
4843    /// Creates a graphics context. The graphics context can be used with any drawable
4844    /// that has the same root and depth as the specified drawable.
4845    ///
4846    /// # Fields
4847    ///
4848    /// * `cid` - The ID with which you will refer to the graphics context, created by
4849    /// `xcb_generate_id`.
4850    /// * `drawable` - Drawable to get the root/depth from.
4851    ///
4852    /// # Errors
4853    ///
4854    /// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
4855    /// * `Match` - TODO: reasons?
4856    /// * `Font` - TODO: reasons?
4857    /// * `Pixmap` - TODO: reasons?
4858    /// * `Value` - TODO: reasons?
4859    /// * `Alloc` - The X server could not allocate the requested resources (no memory?).
4860    ///
4861    /// # See
4862    ///
4863    /// * `xcb_generate_id`: function
4864    fn create_gc<'c, 'input>(&'c self, cid: Gcontext, drawable: Drawable, value_list: &'input CreateGCAux) -> Result<VoidCookie<'c, Self>, ConnectionError>
4865    {
4866        create_gc(self, cid, drawable, value_list)
4867    }
4868    /// change graphics context components.
4869    ///
4870    /// Changes the components specified by `value_mask` for the specified graphics context.
4871    ///
4872    /// # Fields
4873    ///
4874    /// * `gc` - The graphics context to change.
4875    /// * `value_mask` -
4876    /// * `value_list` - Values for each of the components specified in the bitmask `value_mask`. The
4877    /// order has to correspond to the order of possible `value_mask` bits. See the
4878    /// example.
4879    ///
4880    /// # Errors
4881    ///
4882    /// * `Font` - TODO: reasons?
4883    /// * `GContext` - TODO: reasons?
4884    /// * `Match` - TODO: reasons?
4885    /// * `Pixmap` - TODO: reasons?
4886    /// * `Value` - TODO: reasons?
4887    /// * `Alloc` - The X server could not allocate the requested resources (no memory?).
4888    ///
4889    /// # Example
4890    ///
4891    /// ```text
4892    /// /*
4893    ///  * Changes the foreground color component of the specified graphics context.
4894    ///  *
4895    ///  */
4896    /// void my_example(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t fg, uint32_t bg) {
4897    ///     /* C99 allows us to use a compact way of changing a single component: */
4898    ///     xcb_change_gc(conn, gc, XCB_GC_FOREGROUND, (uint32_t[]){ fg });
4899    ///
4900    ///     /* The more explicit way. Beware that the order of values is important! */
4901    ///     uint32_t mask = 0;
4902    ///     mask |= XCB_GC_FOREGROUND;
4903    ///     mask |= XCB_GC_BACKGROUND;
4904    ///
4905    ///     uint32_t values[] = {
4906    ///         fg,
4907    ///         bg
4908    ///     };
4909    ///     xcb_change_gc(conn, gc, mask, values);
4910    ///     xcb_flush(conn);
4911    /// }
4912    /// ```
4913    fn change_gc<'c, 'input>(&'c self, gc: Gcontext, value_list: &'input ChangeGCAux) -> Result<VoidCookie<'c, Self>, ConnectionError>
4914    {
4915        change_gc(self, gc, value_list)
4916    }
4917    fn copy_gc(&self, src_gc: Gcontext, dst_gc: Gcontext, value_mask: GC) -> Result<VoidCookie<'_, Self>, ConnectionError>
4918    {
4919        copy_gc(self, src_gc, dst_gc, value_mask)
4920    }
4921    fn set_dashes<'c, 'input>(&'c self, gc: Gcontext, dash_offset: u16, dashes: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
4922    {
4923        set_dashes(self, gc, dash_offset, dashes)
4924    }
4925    fn set_clip_rectangles<'c, 'input>(&'c self, ordering: ClipOrdering, gc: Gcontext, clip_x_origin: i16, clip_y_origin: i16, rectangles: &'input [Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>
4926    {
4927        set_clip_rectangles(self, ordering, gc, clip_x_origin, clip_y_origin, rectangles)
4928    }
4929    /// Destroys a graphics context.
4930    ///
4931    /// Destroys the specified `gc` and all associated storage.
4932    ///
4933    /// # Fields
4934    ///
4935    /// * `gc` - The graphics context to destroy.
4936    ///
4937    /// # Errors
4938    ///
4939    /// * `GContext` - The specified graphics context does not exist.
4940    fn free_gc(&self, gc: Gcontext) -> Result<VoidCookie<'_, Self>, ConnectionError>
4941    {
4942        free_gc(self, gc)
4943    }
4944    fn clear_area(&self, exposures: bool, window: Window, x: i16, y: i16, width: u16, height: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
4945    {
4946        clear_area(self, exposures, window, x, y, width, height)
4947    }
4948    /// copy areas.
4949    ///
4950    /// Copies the specified rectangle from `src_drawable` to `dst_drawable`.
4951    ///
4952    /// # Fields
4953    ///
4954    /// * `dst_drawable` - The destination drawable (Window or Pixmap).
4955    /// * `src_drawable` - The source drawable (Window or Pixmap).
4956    /// * `gc` - The graphics context to use.
4957    /// * `src_x` - The source X coordinate.
4958    /// * `src_y` - The source Y coordinate.
4959    /// * `dst_x` - The destination X coordinate.
4960    /// * `dst_y` - The destination Y coordinate.
4961    /// * `width` - The width of the area to copy (in pixels).
4962    /// * `height` - The height of the area to copy (in pixels).
4963    ///
4964    /// # Errors
4965    ///
4966    /// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
4967    /// * `GContext` - The specified graphics context does not exist.
4968    /// * `Match` - `src_drawable` has a different root or depth than `dst_drawable`.
4969    fn copy_area(&self, src_drawable: Drawable, dst_drawable: Drawable, gc: Gcontext, src_x: i16, src_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
4970    {
4971        copy_area(self, src_drawable, dst_drawable, gc, src_x, src_y, dst_x, dst_y, width, height)
4972    }
4973    fn copy_plane(&self, src_drawable: Drawable, dst_drawable: Drawable, gc: Gcontext, src_x: i16, src_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16, bit_plane: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>
4974    {
4975        copy_plane(self, src_drawable, dst_drawable, gc, src_x, src_y, dst_x, dst_y, width, height, bit_plane)
4976    }
4977    fn poly_point<'c, 'input>(&'c self, coordinate_mode: CoordMode, drawable: Drawable, gc: Gcontext, points: &'input [Point]) -> Result<VoidCookie<'c, Self>, ConnectionError>
4978    {
4979        poly_point(self, coordinate_mode, drawable, gc, points)
4980    }
4981    /// draw lines.
4982    ///
4983    /// Draws `points_len`-1 lines between each pair of points (point[i], point[i+1])
4984    /// in the `points` array. The lines are drawn in the order listed in the array.
4985    /// They join correctly at all intermediate points, and if the first and last
4986    /// points coincide, the first and last lines also join correctly. For any given
4987    /// line, a pixel is not drawn more than once. If thin (zero line-width) lines
4988    /// intersect, the intersecting pixels are drawn multiple times. If wide lines
4989    /// intersect, the intersecting pixels are drawn only once, as though the entire
4990    /// request were a single, filled shape.
4991    ///
4992    /// # Fields
4993    ///
4994    /// * `drawable` - The drawable to draw the line(s) on.
4995    /// * `gc` - The graphics context to use.
4996    /// * `points_len` - The number of `xcb_point_t` structures in `points`.
4997    /// * `points` - An array of points.
4998    /// * `coordinate_mode` -
4999    ///
5000    /// # Errors
5001    ///
5002    /// * `Drawable` - TODO: reasons?
5003    /// * `GContext` - TODO: reasons?
5004    /// * `Match` - TODO: reasons?
5005    /// * `Value` - TODO: reasons?
5006    ///
5007    /// # Example
5008    ///
5009    /// ```text
5010    /// /*
5011    ///  * Draw a straight line.
5012    ///  *
5013    ///  */
5014    /// void my_example(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc) {
5015    ///     xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, drawable, gc, 2,
5016    ///                   (xcb_point_t[]) { {10, 10}, {100, 10} });
5017    ///     xcb_flush(conn);
5018    /// }
5019    /// ```
5020    fn poly_line<'c, 'input>(&'c self, coordinate_mode: CoordMode, drawable: Drawable, gc: Gcontext, points: &'input [Point]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5021    {
5022        poly_line(self, coordinate_mode, drawable, gc, points)
5023    }
5024    /// draw lines.
5025    ///
5026    /// Draws multiple, unconnected lines. For each segment, a line is drawn between
5027    /// (x1, y1) and (x2, y2). The lines are drawn in the order listed in the array of
5028    /// `xcb_segment_t` structures and does not perform joining at coincident
5029    /// endpoints. For any given line, a pixel is not drawn more than once. If lines
5030    /// intersect, the intersecting pixels are drawn multiple times.
5031    ///
5032    /// TODO: include the xcb_segment_t data structure
5033    ///
5034    /// TODO: an example
5035    ///
5036    /// # Fields
5037    ///
5038    /// * `drawable` - A drawable (Window or Pixmap) to draw on.
5039    /// * `gc` - The graphics context to use.
5040    ///
5041    /// TODO: document which attributes of a gc are used
5042    /// * `segments_len` - The number of `xcb_segment_t` structures in `segments`.
5043    /// * `segments` - An array of `xcb_segment_t` structures.
5044    ///
5045    /// # Errors
5046    ///
5047    /// * `Drawable` - The specified `drawable` does not exist.
5048    /// * `GContext` - The specified `gc` does not exist.
5049    /// * `Match` - TODO: reasons?
5050    fn poly_segment<'c, 'input>(&'c self, drawable: Drawable, gc: Gcontext, segments: &'input [Segment]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5051    {
5052        poly_segment(self, drawable, gc, segments)
5053    }
5054    fn poly_rectangle<'c, 'input>(&'c self, drawable: Drawable, gc: Gcontext, rectangles: &'input [Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5055    {
5056        poly_rectangle(self, drawable, gc, rectangles)
5057    }
5058    fn poly_arc<'c, 'input>(&'c self, drawable: Drawable, gc: Gcontext, arcs: &'input [Arc]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5059    {
5060        poly_arc(self, drawable, gc, arcs)
5061    }
5062    fn fill_poly<'c, 'input>(&'c self, drawable: Drawable, gc: Gcontext, shape: PolyShape, coordinate_mode: CoordMode, points: &'input [Point]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5063    {
5064        fill_poly(self, drawable, gc, shape, coordinate_mode, points)
5065    }
5066    /// Fills rectangles.
5067    ///
5068    /// Fills the specified rectangle(s) in the order listed in the array. For any
5069    /// given rectangle, each pixel is not drawn more than once. If rectangles
5070    /// intersect, the intersecting pixels are drawn multiple times.
5071    ///
5072    /// # Fields
5073    ///
5074    /// * `drawable` - The drawable (Window or Pixmap) to draw on.
5075    /// * `gc` - The graphics context to use.
5076    ///
5077    /// The following graphics context components are used: function, plane-mask,
5078    /// fill-style, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
5079    ///
5080    /// The following graphics context mode-dependent components are used:
5081    /// foreground, background, tile, stipple, tile-stipple-x-origin, and
5082    /// tile-stipple-y-origin.
5083    /// * `rectangles_len` - The number of `xcb_rectangle_t` structures in `rectangles`.
5084    /// * `rectangles` - The rectangles to fill.
5085    ///
5086    /// # Errors
5087    ///
5088    /// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
5089    /// * `GContext` - The specified graphics context does not exist.
5090    /// * `Match` - TODO: reasons?
5091    fn poly_fill_rectangle<'c, 'input>(&'c self, drawable: Drawable, gc: Gcontext, rectangles: &'input [Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5092    {
5093        poly_fill_rectangle(self, drawable, gc, rectangles)
5094    }
5095    fn poly_fill_arc<'c, 'input>(&'c self, drawable: Drawable, gc: Gcontext, arcs: &'input [Arc]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5096    {
5097        poly_fill_arc(self, drawable, gc, arcs)
5098    }
5099    fn put_image<'c, 'input>(&'c self, format: ImageFormat, drawable: Drawable, gc: Gcontext, width: u16, height: u16, dst_x: i16, dst_y: i16, left_pad: u8, depth: u8, data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5100    {
5101        put_image(self, format, drawable, gc, width, height, dst_x, dst_y, left_pad, depth, data)
5102    }
5103    fn get_image(&self, format: ImageFormat, drawable: Drawable, x: i16, y: i16, width: u16, height: u16, plane_mask: u32) -> Result<Cookie<'_, Self, GetImageReply>, ConnectionError>
5104    {
5105        get_image(self, format, drawable, x, y, width, height, plane_mask)
5106    }
5107    fn poly_text8<'c, 'input>(&'c self, drawable: Drawable, gc: Gcontext, x: i16, y: i16, items: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5108    {
5109        poly_text8(self, drawable, gc, x, y, items)
5110    }
5111    fn poly_text16<'c, 'input>(&'c self, drawable: Drawable, gc: Gcontext, x: i16, y: i16, items: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5112    {
5113        poly_text16(self, drawable, gc, x, y, items)
5114    }
5115    /// Draws text.
5116    ///
5117    /// Fills the destination rectangle with the background pixel from `gc`, then
5118    /// paints the text with the foreground pixel from `gc`. The upper-left corner of
5119    /// the filled rectangle is at [x, y - font-ascent]. The width is overall-width,
5120    /// the height is font-ascent + font-descent. The overall-width, font-ascent and
5121    /// font-descent are as returned by `xcb_query_text_extents` (TODO).
5122    ///
5123    /// Note that using X core fonts is deprecated (but still supported) in favor of
5124    /// client-side rendering using Xft.
5125    ///
5126    /// # Fields
5127    ///
5128    /// * `drawable` - The drawable (Window or Pixmap) to draw text on.
5129    /// * `string_len` - The length of the `string`. Note that this parameter limited by 255 due to
5130    /// using 8 bits!
5131    /// * `string` - The string to draw. Only the first 255 characters are relevant due to the data
5132    /// type of `string_len`.
5133    /// * `x` - The x coordinate of the first character, relative to the origin of `drawable`.
5134    /// * `y` - The y coordinate of the first character, relative to the origin of `drawable`.
5135    /// * `gc` - The graphics context to use.
5136    ///
5137    /// The following graphics context components are used: plane-mask, foreground,
5138    /// background, font, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
5139    ///
5140    /// # Errors
5141    ///
5142    /// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
5143    /// * `GContext` - The specified graphics context does not exist.
5144    /// * `Match` - TODO: reasons?
5145    ///
5146    /// # See
5147    ///
5148    /// * `ImageText16`: request
5149    fn image_text8<'c, 'input>(&'c self, drawable: Drawable, gc: Gcontext, x: i16, y: i16, string: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5150    {
5151        image_text8(self, drawable, gc, x, y, string)
5152    }
5153    /// Draws text.
5154    ///
5155    /// Fills the destination rectangle with the background pixel from `gc`, then
5156    /// paints the text with the foreground pixel from `gc`. The upper-left corner of
5157    /// the filled rectangle is at [x, y - font-ascent]. The width is overall-width,
5158    /// the height is font-ascent + font-descent. The overall-width, font-ascent and
5159    /// font-descent are as returned by `xcb_query_text_extents` (TODO).
5160    ///
5161    /// Note that using X core fonts is deprecated (but still supported) in favor of
5162    /// client-side rendering using Xft.
5163    ///
5164    /// # Fields
5165    ///
5166    /// * `drawable` - The drawable (Window or Pixmap) to draw text on.
5167    /// * `string_len` - The length of the `string` in characters. Note that this parameter limited by
5168    /// 255 due to using 8 bits!
5169    /// * `string` - The string to draw. Only the first 255 characters are relevant due to the data
5170    /// type of `string_len`. Every character uses 2 bytes (hence the 16 in this
5171    /// request's name).
5172    /// * `x` - The x coordinate of the first character, relative to the origin of `drawable`.
5173    /// * `y` - The y coordinate of the first character, relative to the origin of `drawable`.
5174    /// * `gc` - The graphics context to use.
5175    ///
5176    /// The following graphics context components are used: plane-mask, foreground,
5177    /// background, font, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
5178    ///
5179    /// # Errors
5180    ///
5181    /// * `Drawable` - The specified `drawable` (Window or Pixmap) does not exist.
5182    /// * `GContext` - The specified graphics context does not exist.
5183    /// * `Match` - TODO: reasons?
5184    ///
5185    /// # See
5186    ///
5187    /// * `ImageText8`: request
5188    fn image_text16<'c, 'input>(&'c self, drawable: Drawable, gc: Gcontext, x: i16, y: i16, string: &'input [Char2b]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5189    {
5190        image_text16(self, drawable, gc, x, y, string)
5191    }
5192    fn create_colormap(&self, alloc: ColormapAlloc, mid: Colormap, window: Window, visual: Visualid) -> Result<VoidCookie<'_, Self>, ConnectionError>
5193    {
5194        create_colormap(self, alloc, mid, window, visual)
5195    }
5196    fn free_colormap(&self, cmap: Colormap) -> Result<VoidCookie<'_, Self>, ConnectionError>
5197    {
5198        free_colormap(self, cmap)
5199    }
5200    fn copy_colormap_and_free(&self, mid: Colormap, src_cmap: Colormap) -> Result<VoidCookie<'_, Self>, ConnectionError>
5201    {
5202        copy_colormap_and_free(self, mid, src_cmap)
5203    }
5204    fn install_colormap(&self, cmap: Colormap) -> Result<VoidCookie<'_, Self>, ConnectionError>
5205    {
5206        install_colormap(self, cmap)
5207    }
5208    fn uninstall_colormap(&self, cmap: Colormap) -> Result<VoidCookie<'_, Self>, ConnectionError>
5209    {
5210        uninstall_colormap(self, cmap)
5211    }
5212    fn list_installed_colormaps(&self, window: Window) -> Result<Cookie<'_, Self, ListInstalledColormapsReply>, ConnectionError>
5213    {
5214        list_installed_colormaps(self, window)
5215    }
5216    /// Allocate a color.
5217    ///
5218    /// Allocates a read-only colormap entry corresponding to the closest RGB value
5219    /// supported by the hardware. If you are using TrueColor, you can take a shortcut
5220    /// and directly calculate the color pixel value to avoid the round trip. But, for
5221    /// example, on 16-bit color setups (VNC), you can easily get the closest supported
5222    /// RGB value to the RGB value you are specifying.
5223    ///
5224    /// # Fields
5225    ///
5226    /// * `cmap` - TODO
5227    /// * `red` - The red value of your color.
5228    /// * `green` - The green value of your color.
5229    /// * `blue` - The blue value of your color.
5230    ///
5231    /// # Errors
5232    ///
5233    /// * `Colormap` - The specified colormap `cmap` does not exist.
5234    fn alloc_color(&self, cmap: Colormap, red: u16, green: u16, blue: u16) -> Result<Cookie<'_, Self, AllocColorReply>, ConnectionError>
5235    {
5236        alloc_color(self, cmap, red, green, blue)
5237    }
5238    fn alloc_named_color<'c, 'input>(&'c self, cmap: Colormap, name: &'input [u8]) -> Result<Cookie<'c, Self, AllocNamedColorReply>, ConnectionError>
5239    {
5240        alloc_named_color(self, cmap, name)
5241    }
5242    fn alloc_color_cells(&self, contiguous: bool, cmap: Colormap, colors: u16, planes: u16) -> Result<Cookie<'_, Self, AllocColorCellsReply>, ConnectionError>
5243    {
5244        alloc_color_cells(self, contiguous, cmap, colors, planes)
5245    }
5246    fn alloc_color_planes(&self, contiguous: bool, cmap: Colormap, colors: u16, reds: u16, greens: u16, blues: u16) -> Result<Cookie<'_, Self, AllocColorPlanesReply>, ConnectionError>
5247    {
5248        alloc_color_planes(self, contiguous, cmap, colors, reds, greens, blues)
5249    }
5250    fn free_colors<'c, 'input>(&'c self, cmap: Colormap, plane_mask: u32, pixels: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5251    {
5252        free_colors(self, cmap, plane_mask, pixels)
5253    }
5254    fn store_colors<'c, 'input>(&'c self, cmap: Colormap, items: &'input [Coloritem]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5255    {
5256        store_colors(self, cmap, items)
5257    }
5258    fn store_named_color<'c, 'input>(&'c self, flags: ColorFlag, cmap: Colormap, pixel: u32, name: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5259    {
5260        store_named_color(self, flags, cmap, pixel, name)
5261    }
5262    fn query_colors<'c, 'input>(&'c self, cmap: Colormap, pixels: &'input [u32]) -> Result<Cookie<'c, Self, QueryColorsReply>, ConnectionError>
5263    {
5264        query_colors(self, cmap, pixels)
5265    }
5266    fn lookup_color<'c, 'input>(&'c self, cmap: Colormap, name: &'input [u8]) -> Result<Cookie<'c, Self, LookupColorReply>, ConnectionError>
5267    {
5268        lookup_color(self, cmap, name)
5269    }
5270    fn create_cursor<A>(&self, cid: Cursor, source: Pixmap, mask: A, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16, x: u16, y: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
5271    where
5272        A: Into<Pixmap>,
5273    {
5274        create_cursor(self, cid, source, mask, fore_red, fore_green, fore_blue, back_red, back_green, back_blue, x, y)
5275    }
5276    /// create cursor.
5277    ///
5278    /// Creates a cursor from a font glyph. X provides a set of standard cursor shapes
5279    /// in a special font named cursor. Applications are encouraged to use this
5280    /// interface for their cursors because the font can be customized for the
5281    /// individual display type.
5282    ///
5283    /// All pixels which are set to 1 in the source will use the foreground color (as
5284    /// specified by `fore_red`, `fore_green` and `fore_blue`). All pixels set to 0
5285    /// will use the background color (as specified by `back_red`, `back_green` and
5286    /// `back_blue`).
5287    ///
5288    /// # Fields
5289    ///
5290    /// * `cid` - The ID with which you will refer to the cursor, created by `xcb_generate_id`.
5291    /// * `source_font` - In which font to look for the cursor glyph.
5292    /// * `mask_font` - In which font to look for the mask glyph.
5293    /// * `source_char` - The glyph of `source_font` to use.
5294    /// * `mask_char` - The glyph of `mask_font` to use as a mask: Pixels which are set to 1 define
5295    /// which source pixels are displayed. All pixels which are set to 0 are not
5296    /// displayed.
5297    /// * `fore_red` - The red value of the foreground color.
5298    /// * `fore_green` - The green value of the foreground color.
5299    /// * `fore_blue` - The blue value of the foreground color.
5300    /// * `back_red` - The red value of the background color.
5301    /// * `back_green` - The green value of the background color.
5302    /// * `back_blue` - The blue value of the background color.
5303    ///
5304    /// # Errors
5305    ///
5306    /// * `Alloc` - The X server could not allocate the requested resources (no memory?).
5307    /// * `Font` - The specified `source_font` or `mask_font` does not exist.
5308    /// * `Value` - Either `source_char` or `mask_char` are not defined in `source_font` or `mask_font`, respectively.
5309    fn create_glyph_cursor<A>(&self, cid: Cursor, source_font: Font, mask_font: A, source_char: u16, mask_char: u16, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
5310    where
5311        A: Into<Font>,
5312    {
5313        create_glyph_cursor(self, cid, source_font, mask_font, source_char, mask_char, fore_red, fore_green, fore_blue, back_red, back_green, back_blue)
5314    }
5315    /// Deletes a cursor.
5316    ///
5317    /// Deletes the association between the cursor resource ID and the specified
5318    /// cursor. The cursor is freed when no other resource references it.
5319    ///
5320    /// # Fields
5321    ///
5322    /// * `cursor` - The cursor to destroy.
5323    ///
5324    /// # Errors
5325    ///
5326    /// * `Cursor` - The specified cursor does not exist.
5327    fn free_cursor(&self, cursor: Cursor) -> Result<VoidCookie<'_, Self>, ConnectionError>
5328    {
5329        free_cursor(self, cursor)
5330    }
5331    fn recolor_cursor(&self, cursor: Cursor, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
5332    {
5333        recolor_cursor(self, cursor, fore_red, fore_green, fore_blue, back_red, back_green, back_blue)
5334    }
5335    fn query_best_size(&self, class: QueryShapeOf, drawable: Drawable, width: u16, height: u16) -> Result<Cookie<'_, Self, QueryBestSizeReply>, ConnectionError>
5336    {
5337        query_best_size(self, class, drawable, width, height)
5338    }
5339    /// check if extension is present.
5340    ///
5341    /// Determines if the specified extension is present on this X11 server.
5342    ///
5343    /// Every extension has a unique `major_opcode` to identify requests, the minor
5344    /// opcodes and request formats are extension-specific. If the extension provides
5345    /// events and errors, the `first_event` and `first_error` fields in the reply are
5346    /// set accordingly.
5347    ///
5348    /// There should rarely be a need to use this request directly, XCB provides the
5349    /// `xcb_get_extension_data` function instead.
5350    ///
5351    /// # Fields
5352    ///
5353    /// * `name_len` - The length of `name` in bytes.
5354    /// * `name` - The name of the extension to query, for example "RANDR". This is case
5355    /// sensitive!
5356    ///
5357    /// # See
5358    ///
5359    /// * `xdpyinfo`: program
5360    /// * `xcb_get_extension_data`: function
5361    fn query_extension<'c, 'input>(&'c self, name: &'input [u8]) -> Result<Cookie<'c, Self, QueryExtensionReply>, ConnectionError>
5362    {
5363        query_extension(self, name)
5364    }
5365    fn list_extensions(&self) -> Result<Cookie<'_, Self, ListExtensionsReply>, ConnectionError>
5366    {
5367        list_extensions(self)
5368    }
5369    fn change_keyboard_mapping<'c, 'input>(&'c self, keycode_count: u8, first_keycode: Keycode, keysyms_per_keycode: u8, keysyms: &'input [Keysym]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5370    {
5371        change_keyboard_mapping(self, keycode_count, first_keycode, keysyms_per_keycode, keysyms)
5372    }
5373    fn get_keyboard_mapping(&self, first_keycode: Keycode, count: u8) -> Result<Cookie<'_, Self, GetKeyboardMappingReply>, ConnectionError>
5374    {
5375        get_keyboard_mapping(self, first_keycode, count)
5376    }
5377    fn change_keyboard_control<'c, 'input>(&'c self, value_list: &'input ChangeKeyboardControlAux) -> Result<VoidCookie<'c, Self>, ConnectionError>
5378    {
5379        change_keyboard_control(self, value_list)
5380    }
5381    fn get_keyboard_control(&self) -> Result<Cookie<'_, Self, GetKeyboardControlReply>, ConnectionError>
5382    {
5383        get_keyboard_control(self)
5384    }
5385    fn bell(&self, percent: i8) -> Result<VoidCookie<'_, Self>, ConnectionError>
5386    {
5387        bell(self, percent)
5388    }
5389    fn change_pointer_control(&self, acceleration_numerator: i16, acceleration_denominator: i16, threshold: i16, do_acceleration: bool, do_threshold: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>
5390    {
5391        change_pointer_control(self, acceleration_numerator, acceleration_denominator, threshold, do_acceleration, do_threshold)
5392    }
5393    fn get_pointer_control(&self) -> Result<Cookie<'_, Self, GetPointerControlReply>, ConnectionError>
5394    {
5395        get_pointer_control(self)
5396    }
5397    fn set_screen_saver(&self, timeout: i16, interval: i16, prefer_blanking: Blanking, allow_exposures: Exposures) -> Result<VoidCookie<'_, Self>, ConnectionError>
5398    {
5399        set_screen_saver(self, timeout, interval, prefer_blanking, allow_exposures)
5400    }
5401    fn get_screen_saver(&self) -> Result<Cookie<'_, Self, GetScreenSaverReply>, ConnectionError>
5402    {
5403        get_screen_saver(self)
5404    }
5405    fn change_hosts<'c, 'input>(&'c self, mode: HostMode, family: Family, address: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5406    {
5407        change_hosts(self, mode, family, address)
5408    }
5409    fn list_hosts(&self) -> Result<Cookie<'_, Self, ListHostsReply>, ConnectionError>
5410    {
5411        list_hosts(self)
5412    }
5413    fn set_access_control(&self, mode: AccessControl) -> Result<VoidCookie<'_, Self>, ConnectionError>
5414    {
5415        set_access_control(self, mode)
5416    }
5417    fn set_close_down_mode(&self, mode: CloseDown) -> Result<VoidCookie<'_, Self>, ConnectionError>
5418    {
5419        set_close_down_mode(self, mode)
5420    }
5421    /// kills a client.
5422    ///
5423    /// Forces a close down of the client that created the specified `resource`.
5424    ///
5425    /// # Fields
5426    ///
5427    /// * `resource` - Any resource belonging to the client (for example a Window), used to identify
5428    /// the client connection.
5429    ///
5430    /// The special value of `XCB_KILL_ALL_TEMPORARY`, the resources of all clients
5431    /// that have terminated in `RetainTemporary` (TODO) are destroyed.
5432    ///
5433    /// # Errors
5434    ///
5435    /// * `Value` - The specified `resource` does not exist.
5436    ///
5437    /// # See
5438    ///
5439    /// * `xkill`: program
5440    fn kill_client<A>(&self, resource: A) -> Result<VoidCookie<'_, Self>, ConnectionError>
5441    where
5442        A: Into<u32>,
5443    {
5444        kill_client(self, resource)
5445    }
5446    fn rotate_properties<'c, 'input>(&'c self, window: Window, delta: i16, atoms: &'input [Atom]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5447    {
5448        rotate_properties(self, window, delta, atoms)
5449    }
5450    fn force_screen_saver(&self, mode: ScreenSaver) -> Result<VoidCookie<'_, Self>, ConnectionError>
5451    {
5452        force_screen_saver(self, mode)
5453    }
5454    fn set_pointer_mapping<'c, 'input>(&'c self, map: &'input [u8]) -> Result<Cookie<'c, Self, SetPointerMappingReply>, ConnectionError>
5455    {
5456        set_pointer_mapping(self, map)
5457    }
5458    fn get_pointer_mapping(&self) -> Result<Cookie<'_, Self, GetPointerMappingReply>, ConnectionError>
5459    {
5460        get_pointer_mapping(self)
5461    }
5462    fn set_modifier_mapping<'c, 'input>(&'c self, keycodes: &'input [Keycode]) -> Result<Cookie<'c, Self, SetModifierMappingReply>, ConnectionError>
5463    {
5464        set_modifier_mapping(self, keycodes)
5465    }
5466    fn get_modifier_mapping(&self) -> Result<Cookie<'_, Self, GetModifierMappingReply>, ConnectionError>
5467    {
5468        get_modifier_mapping(self)
5469    }
5470    fn no_operation(&self) -> Result<VoidCookie<'_, Self>, ConnectionError>
5471    {
5472        no_operation(self)
5473    }
5474}
5475
5476impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
5477
5478/// A RAII-like wrapper around a [Pixmap].
5479///
5480/// Instances of this struct represent a Pixmap that is freed in `Drop`.
5481///
5482/// Any errors during `Drop` are silently ignored. Most likely an error here means that your
5483/// X11 connection is broken and later requests will also fail.
5484#[derive(Debug)]
5485pub struct PixmapWrapper<C: RequestConnection>(C, Pixmap);
5486
5487impl<C: RequestConnection> PixmapWrapper<C>
5488{
5489    /// Assume ownership of the given resource and destroy it in `Drop`.
5490    pub fn for_pixmap(conn: C, id: Pixmap) -> Self {
5491        PixmapWrapper(conn, id)
5492    }
5493
5494    /// Get the XID of the wrapped resource
5495    pub fn pixmap(&self) -> Pixmap {
5496        self.1
5497    }
5498
5499    /// Assume ownership of the XID of the wrapped resource
5500    ///
5501    /// This function destroys this wrapper without freeing the underlying resource.
5502    pub fn into_pixmap(self) -> Pixmap {
5503        let id = self.1;
5504        std::mem::forget(self);
5505        id
5506    }
5507}
5508
5509impl<'c, C: X11Connection> PixmapWrapper<&'c C>
5510{
5511    /// Create a new Pixmap and return a Pixmap wrapper and a cookie.
5512    ///
5513    /// This is a thin wrapper around [create_pixmap] that allocates an id for the Pixmap.
5514    /// This function returns the resulting `PixmapWrapper` that owns the created Pixmap and frees
5515    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
5516    /// [create_pixmap].
5517    ///
5518    /// Errors can come from the call to [X11Connection::generate_id] or [create_pixmap].
5519    pub fn create_pixmap_and_get_cookie(conn: &'c C, depth: u8, drawable: Drawable, width: u16, height: u16) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
5520    {
5521        let pid = conn.generate_id()?;
5522        let cookie = create_pixmap(conn, depth, pid, drawable, width, height)?;
5523        Ok((Self::for_pixmap(conn, pid), cookie))
5524    }
5525}
5526impl<C: X11Connection> PixmapWrapper<C>
5527{
5528    /// Create a new Pixmap and return a Pixmap wrapper
5529    ///
5530    /// This is a thin wrapper around [create_pixmap] that allocates an id for the Pixmap.
5531    /// This function returns the resulting `PixmapWrapper` that owns the created Pixmap and frees
5532    /// it in `Drop`.
5533    ///
5534    /// Errors can come from the call to [X11Connection::generate_id] or [create_pixmap].
5535    pub fn create_pixmap(conn: C, depth: u8, drawable: Drawable, width: u16, height: u16) -> Result<Self, ReplyOrIdError>
5536    {
5537        let pid = conn.generate_id()?;
5538        let _ = create_pixmap(&conn, depth, pid, drawable, width, height)?;
5539        Ok(Self::for_pixmap(conn, pid))
5540    }
5541}
5542
5543impl<C: RequestConnection> From<&PixmapWrapper<C>> for Pixmap {
5544    fn from(from: &PixmapWrapper<C>) -> Self {
5545        from.1
5546    }
5547}
5548
5549impl<C: RequestConnection> Drop for PixmapWrapper<C> {
5550    fn drop(&mut self) {
5551        let _ = free_pixmap(&self.0, self.1);
5552    }
5553}
5554
5555/// A RAII-like wrapper around a [Window].
5556///
5557/// Instances of this struct represent a Window that is freed in `Drop`.
5558///
5559/// Any errors during `Drop` are silently ignored. Most likely an error here means that your
5560/// X11 connection is broken and later requests will also fail.
5561#[derive(Debug)]
5562pub struct WindowWrapper<C: RequestConnection>(C, Window);
5563
5564impl<C: RequestConnection> WindowWrapper<C>
5565{
5566    /// Assume ownership of the given resource and destroy it in `Drop`.
5567    pub fn for_window(conn: C, id: Window) -> Self {
5568        WindowWrapper(conn, id)
5569    }
5570
5571    /// Get the XID of the wrapped resource
5572    pub fn window(&self) -> Window {
5573        self.1
5574    }
5575
5576    /// Assume ownership of the XID of the wrapped resource
5577    ///
5578    /// This function destroys this wrapper without freeing the underlying resource.
5579    pub fn into_window(self) -> Window {
5580        let id = self.1;
5581        std::mem::forget(self);
5582        id
5583    }
5584}
5585
5586impl<'c, C: X11Connection> WindowWrapper<&'c C>
5587{
5588    /// Create a new Window and return a Window wrapper and a cookie.
5589    ///
5590    /// This is a thin wrapper around [create_window] that allocates an id for the Window.
5591    /// This function returns the resulting `WindowWrapper` that owns the created Window and frees
5592    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
5593    /// [create_window].
5594    ///
5595    /// Errors can come from the call to [X11Connection::generate_id] or [create_window].
5596    pub fn create_window_and_get_cookie(conn: &'c C, depth: u8, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, class: WindowClass, visual: Visualid, value_list: &CreateWindowAux) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
5597    {
5598        let wid = conn.generate_id()?;
5599        let cookie = create_window(conn, depth, wid, parent, x, y, width, height, border_width, class, visual, value_list)?;
5600        Ok((Self::for_window(conn, wid), cookie))
5601    }
5602}
5603impl<C: X11Connection> WindowWrapper<C>
5604{
5605    /// Create a new Window and return a Window wrapper
5606    ///
5607    /// This is a thin wrapper around [create_window] that allocates an id for the Window.
5608    /// This function returns the resulting `WindowWrapper` that owns the created Window and frees
5609    /// it in `Drop`.
5610    ///
5611    /// Errors can come from the call to [X11Connection::generate_id] or [create_window].
5612    pub fn create_window(conn: C, depth: u8, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, class: WindowClass, visual: Visualid, value_list: &CreateWindowAux) -> Result<Self, ReplyOrIdError>
5613    {
5614        let wid = conn.generate_id()?;
5615        let _ = create_window(&conn, depth, wid, parent, x, y, width, height, border_width, class, visual, value_list)?;
5616        Ok(Self::for_window(conn, wid))
5617    }
5618}
5619
5620impl<C: RequestConnection> From<&WindowWrapper<C>> for Window {
5621    fn from(from: &WindowWrapper<C>) -> Self {
5622        from.1
5623    }
5624}
5625
5626impl<C: RequestConnection> Drop for WindowWrapper<C> {
5627    fn drop(&mut self) {
5628        let _ = destroy_window(&self.0, self.1);
5629    }
5630}
5631
5632/// A RAII-like wrapper around a [Font].
5633///
5634/// Instances of this struct represent a Font that is freed in `Drop`.
5635///
5636/// Any errors during `Drop` are silently ignored. Most likely an error here means that your
5637/// X11 connection is broken and later requests will also fail.
5638#[derive(Debug)]
5639pub struct FontWrapper<C: RequestConnection>(C, Font);
5640
5641impl<C: RequestConnection> FontWrapper<C>
5642{
5643    /// Assume ownership of the given resource and destroy it in `Drop`.
5644    pub fn for_font(conn: C, id: Font) -> Self {
5645        FontWrapper(conn, id)
5646    }
5647
5648    /// Get the XID of the wrapped resource
5649    pub fn font(&self) -> Font {
5650        self.1
5651    }
5652
5653    /// Assume ownership of the XID of the wrapped resource
5654    ///
5655    /// This function destroys this wrapper without freeing the underlying resource.
5656    pub fn into_font(self) -> Font {
5657        let id = self.1;
5658        std::mem::forget(self);
5659        id
5660    }
5661}
5662
5663impl<'c, C: X11Connection> FontWrapper<&'c C>
5664{
5665    /// Create a new Font and return a Font wrapper and a cookie.
5666    ///
5667    /// This is a thin wrapper around [open_font] that allocates an id for the Font.
5668    /// This function returns the resulting `FontWrapper` that owns the created Font and frees
5669    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
5670    /// [open_font].
5671    ///
5672    /// Errors can come from the call to [X11Connection::generate_id] or [open_font].
5673    pub fn open_font_and_get_cookie(conn: &'c C, name: &[u8]) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
5674    {
5675        let fid = conn.generate_id()?;
5676        let cookie = open_font(conn, fid, name)?;
5677        Ok((Self::for_font(conn, fid), cookie))
5678    }
5679}
5680impl<C: X11Connection> FontWrapper<C>
5681{
5682    /// Create a new Font and return a Font wrapper
5683    ///
5684    /// This is a thin wrapper around [open_font] that allocates an id for the Font.
5685    /// This function returns the resulting `FontWrapper` that owns the created Font and frees
5686    /// it in `Drop`.
5687    ///
5688    /// Errors can come from the call to [X11Connection::generate_id] or [open_font].
5689    pub fn open_font(conn: C, name: &[u8]) -> Result<Self, ReplyOrIdError>
5690    {
5691        let fid = conn.generate_id()?;
5692        let _ = open_font(&conn, fid, name)?;
5693        Ok(Self::for_font(conn, fid))
5694    }
5695}
5696
5697impl<C: RequestConnection> From<&FontWrapper<C>> for Font {
5698    fn from(from: &FontWrapper<C>) -> Self {
5699        from.1
5700    }
5701}
5702
5703impl<C: RequestConnection> Drop for FontWrapper<C> {
5704    fn drop(&mut self) {
5705        let _ = close_font(&self.0, self.1);
5706    }
5707}
5708
5709/// A RAII-like wrapper around a [Gcontext].
5710///
5711/// Instances of this struct represent a Gcontext that is freed in `Drop`.
5712///
5713/// Any errors during `Drop` are silently ignored. Most likely an error here means that your
5714/// X11 connection is broken and later requests will also fail.
5715#[derive(Debug)]
5716pub struct GcontextWrapper<C: RequestConnection>(C, Gcontext);
5717
5718impl<C: RequestConnection> GcontextWrapper<C>
5719{
5720    /// Assume ownership of the given resource and destroy it in `Drop`.
5721    pub fn for_gcontext(conn: C, id: Gcontext) -> Self {
5722        GcontextWrapper(conn, id)
5723    }
5724
5725    /// Get the XID of the wrapped resource
5726    pub fn gcontext(&self) -> Gcontext {
5727        self.1
5728    }
5729
5730    /// Assume ownership of the XID of the wrapped resource
5731    ///
5732    /// This function destroys this wrapper without freeing the underlying resource.
5733    pub fn into_gcontext(self) -> Gcontext {
5734        let id = self.1;
5735        std::mem::forget(self);
5736        id
5737    }
5738}
5739
5740impl<'c, C: X11Connection> GcontextWrapper<&'c C>
5741{
5742    /// Create a new Gcontext and return a Gcontext wrapper and a cookie.
5743    ///
5744    /// This is a thin wrapper around [create_gc] that allocates an id for the Gcontext.
5745    /// This function returns the resulting `GcontextWrapper` that owns the created Gcontext and frees
5746    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
5747    /// [create_gc].
5748    ///
5749    /// Errors can come from the call to [X11Connection::generate_id] or [create_gc].
5750    pub fn create_gc_and_get_cookie(conn: &'c C, drawable: Drawable, value_list: &CreateGCAux) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
5751    {
5752        let cid = conn.generate_id()?;
5753        let cookie = create_gc(conn, cid, drawable, value_list)?;
5754        Ok((Self::for_gcontext(conn, cid), cookie))
5755    }
5756}
5757impl<C: X11Connection> GcontextWrapper<C>
5758{
5759    /// Create a new Gcontext and return a Gcontext wrapper
5760    ///
5761    /// This is a thin wrapper around [create_gc] that allocates an id for the Gcontext.
5762    /// This function returns the resulting `GcontextWrapper` that owns the created Gcontext and frees
5763    /// it in `Drop`.
5764    ///
5765    /// Errors can come from the call to [X11Connection::generate_id] or [create_gc].
5766    pub fn create_gc(conn: C, drawable: Drawable, value_list: &CreateGCAux) -> Result<Self, ReplyOrIdError>
5767    {
5768        let cid = conn.generate_id()?;
5769        let _ = create_gc(&conn, cid, drawable, value_list)?;
5770        Ok(Self::for_gcontext(conn, cid))
5771    }
5772}
5773
5774impl<C: RequestConnection> From<&GcontextWrapper<C>> for Gcontext {
5775    fn from(from: &GcontextWrapper<C>) -> Self {
5776        from.1
5777    }
5778}
5779
5780impl<C: RequestConnection> Drop for GcontextWrapper<C> {
5781    fn drop(&mut self) {
5782        let _ = free_gc(&self.0, self.1);
5783    }
5784}
5785
5786/// A RAII-like wrapper around a [Colormap].
5787///
5788/// Instances of this struct represent a Colormap that is freed in `Drop`.
5789///
5790/// Any errors during `Drop` are silently ignored. Most likely an error here means that your
5791/// X11 connection is broken and later requests will also fail.
5792#[derive(Debug)]
5793pub struct ColormapWrapper<C: RequestConnection>(C, Colormap);
5794
5795impl<C: RequestConnection> ColormapWrapper<C>
5796{
5797    /// Assume ownership of the given resource and destroy it in `Drop`.
5798    pub fn for_colormap(conn: C, id: Colormap) -> Self {
5799        ColormapWrapper(conn, id)
5800    }
5801
5802    /// Get the XID of the wrapped resource
5803    pub fn colormap(&self) -> Colormap {
5804        self.1
5805    }
5806
5807    /// Assume ownership of the XID of the wrapped resource
5808    ///
5809    /// This function destroys this wrapper without freeing the underlying resource.
5810    pub fn into_colormap(self) -> Colormap {
5811        let id = self.1;
5812        std::mem::forget(self);
5813        id
5814    }
5815}
5816
5817impl<'c, C: X11Connection> ColormapWrapper<&'c C>
5818{
5819    /// Create a new Colormap and return a Colormap wrapper and a cookie.
5820    ///
5821    /// This is a thin wrapper around [create_colormap] that allocates an id for the Colormap.
5822    /// This function returns the resulting `ColormapWrapper` that owns the created Colormap and frees
5823    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
5824    /// [create_colormap].
5825    ///
5826    /// Errors can come from the call to [X11Connection::generate_id] or [create_colormap].
5827    pub fn create_colormap_and_get_cookie(conn: &'c C, alloc: ColormapAlloc, window: Window, visual: Visualid) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
5828    {
5829        let mid = conn.generate_id()?;
5830        let cookie = create_colormap(conn, alloc, mid, window, visual)?;
5831        Ok((Self::for_colormap(conn, mid), cookie))
5832    }
5833}
5834impl<C: X11Connection> ColormapWrapper<C>
5835{
5836    /// Create a new Colormap and return a Colormap wrapper
5837    ///
5838    /// This is a thin wrapper around [create_colormap] that allocates an id for the Colormap.
5839    /// This function returns the resulting `ColormapWrapper` that owns the created Colormap and frees
5840    /// it in `Drop`.
5841    ///
5842    /// Errors can come from the call to [X11Connection::generate_id] or [create_colormap].
5843    pub fn create_colormap(conn: C, alloc: ColormapAlloc, window: Window, visual: Visualid) -> Result<Self, ReplyOrIdError>
5844    {
5845        let mid = conn.generate_id()?;
5846        let _ = create_colormap(&conn, alloc, mid, window, visual)?;
5847        Ok(Self::for_colormap(conn, mid))
5848    }
5849}
5850
5851impl<C: RequestConnection> From<&ColormapWrapper<C>> for Colormap {
5852    fn from(from: &ColormapWrapper<C>) -> Self {
5853        from.1
5854    }
5855}
5856
5857impl<C: RequestConnection> Drop for ColormapWrapper<C> {
5858    fn drop(&mut self) {
5859        let _ = free_colormap(&self.0, self.1);
5860    }
5861}
5862
5863/// A RAII-like wrapper around a [Cursor].
5864///
5865/// Instances of this struct represent a Cursor that is freed in `Drop`.
5866///
5867/// Any errors during `Drop` are silently ignored. Most likely an error here means that your
5868/// X11 connection is broken and later requests will also fail.
5869#[derive(Debug)]
5870pub struct CursorWrapper<C: RequestConnection>(C, Cursor);
5871
5872impl<C: RequestConnection> CursorWrapper<C>
5873{
5874    /// Assume ownership of the given resource and destroy it in `Drop`.
5875    pub fn for_cursor(conn: C, id: Cursor) -> Self {
5876        CursorWrapper(conn, id)
5877    }
5878
5879    /// Get the XID of the wrapped resource
5880    pub fn cursor(&self) -> Cursor {
5881        self.1
5882    }
5883
5884    /// Assume ownership of the XID of the wrapped resource
5885    ///
5886    /// This function destroys this wrapper without freeing the underlying resource.
5887    pub fn into_cursor(self) -> Cursor {
5888        let id = self.1;
5889        std::mem::forget(self);
5890        id
5891    }
5892}
5893
5894impl<'c, C: X11Connection> CursorWrapper<&'c C>
5895{
5896    /// Create a new Cursor and return a Cursor wrapper and a cookie.
5897    ///
5898    /// This is a thin wrapper around [create_cursor] that allocates an id for the Cursor.
5899    /// This function returns the resulting `CursorWrapper` that owns the created Cursor and frees
5900    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
5901    /// [create_cursor].
5902    ///
5903    /// Errors can come from the call to [X11Connection::generate_id] or [create_cursor].
5904    pub fn create_cursor_and_get_cookie<A>(conn: &'c C, source: Pixmap, mask: A, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16, x: u16, y: u16) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
5905    where
5906        A: Into<Pixmap>,
5907    {
5908        let cid = conn.generate_id()?;
5909        let cookie = create_cursor(conn, cid, source, mask, fore_red, fore_green, fore_blue, back_red, back_green, back_blue, x, y)?;
5910        Ok((Self::for_cursor(conn, cid), cookie))
5911    }
5912}
5913impl<C: X11Connection> CursorWrapper<C>
5914{
5915    /// Create a new Cursor and return a Cursor wrapper
5916    ///
5917    /// This is a thin wrapper around [create_cursor] that allocates an id for the Cursor.
5918    /// This function returns the resulting `CursorWrapper` that owns the created Cursor and frees
5919    /// it in `Drop`.
5920    ///
5921    /// Errors can come from the call to [X11Connection::generate_id] or [create_cursor].
5922    pub fn create_cursor<A>(conn: C, source: Pixmap, mask: A, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16, x: u16, y: u16) -> Result<Self, ReplyOrIdError>
5923    where
5924        A: Into<Pixmap>,
5925    {
5926        let cid = conn.generate_id()?;
5927        let _ = create_cursor(&conn, cid, source, mask, fore_red, fore_green, fore_blue, back_red, back_green, back_blue, x, y)?;
5928        Ok(Self::for_cursor(conn, cid))
5929    }
5930}
5931
5932impl<'c, C: X11Connection> CursorWrapper<&'c C>
5933{
5934    /// Create a new Cursor and return a Cursor wrapper and a cookie.
5935    ///
5936    /// This is a thin wrapper around [create_glyph_cursor] that allocates an id for the Cursor.
5937    /// This function returns the resulting `CursorWrapper` that owns the created Cursor and frees
5938    /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to
5939    /// [create_glyph_cursor].
5940    ///
5941    /// Errors can come from the call to [X11Connection::generate_id] or [create_glyph_cursor].
5942    pub fn create_glyph_cursor_and_get_cookie<A>(conn: &'c C, source_font: Font, mask_font: A, source_char: u16, mask_char: u16, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError>
5943    where
5944        A: Into<Font>,
5945    {
5946        let cid = conn.generate_id()?;
5947        let cookie = create_glyph_cursor(conn, cid, source_font, mask_font, source_char, mask_char, fore_red, fore_green, fore_blue, back_red, back_green, back_blue)?;
5948        Ok((Self::for_cursor(conn, cid), cookie))
5949    }
5950}
5951impl<C: X11Connection> CursorWrapper<C>
5952{
5953    /// Create a new Cursor and return a Cursor wrapper
5954    ///
5955    /// This is a thin wrapper around [create_glyph_cursor] that allocates an id for the Cursor.
5956    /// This function returns the resulting `CursorWrapper` that owns the created Cursor and frees
5957    /// it in `Drop`.
5958    ///
5959    /// Errors can come from the call to [X11Connection::generate_id] or [create_glyph_cursor].
5960    pub fn create_glyph_cursor<A>(conn: C, source_font: Font, mask_font: A, source_char: u16, mask_char: u16, fore_red: u16, fore_green: u16, fore_blue: u16, back_red: u16, back_green: u16, back_blue: u16) -> Result<Self, ReplyOrIdError>
5961    where
5962        A: Into<Font>,
5963    {
5964        let cid = conn.generate_id()?;
5965        let _ = create_glyph_cursor(&conn, cid, source_font, mask_font, source_char, mask_char, fore_red, fore_green, fore_blue, back_red, back_green, back_blue)?;
5966        Ok(Self::for_cursor(conn, cid))
5967    }
5968}
5969
5970impl<C: RequestConnection> From<&CursorWrapper<C>> for Cursor {
5971    fn from(from: &CursorWrapper<C>) -> Self {
5972        from.1
5973    }
5974}
5975
5976impl<C: RequestConnection> Drop for CursorWrapper<C> {
5977    fn drop(&mut self) {
5978        let _ = free_cursor(&self.0, self.1);
5979    }
5980}