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