1 module xcb.xcb_icccm;
2 /*
3  * Copyright (C) 2008 Arnaud Fontaine <arnau@debian.org>
4  * Copyright (C) 2007-2008 Vincent Torri <vtorri@univ-evry.fr>
5  *
6  * Permission is hereby granted, free of charge, to any person
7  * obtaining a copy of this software and associated documentation
8  * files (the "Software"), to deal in the Software without
9  * restriction, including without limitation the rights to use, copy,
10  * modify, merge, publish, distribute, sublicense, and/or sell copies
11  * of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  *
25  * Except as contained in this notice, the names of the authors or
26  * their institutions shall not be used in advertising or otherwise to
27  * promote the sale, use or other dealings in this Software without
28  * prior written authorization from the authors.
29  */
30 
31 /**
32  * @defgroup xcb__icccm_t XCB ICCCM Functions
33  *
34  * These functions allow easy handling of the protocol described in the
35  * Inter-Client Communication Conventions Manual.
36  *
37  * @{
38  */
39 
40 import xcb.xcb;
41 
42 /**
43  * @brief TextProperty reply structure.
44  */
45 struct xcb_icccm_get_text_property_reply_t {
46 /** Store reply to avoid memory allocation, should normally not be
47     used directly */
48 xcb_get_property_reply_t *_reply;
49 /** Encoding used */
50 xcb_atom_t encoding;
51 /** Length of the name field above */
52 uint name_len;
53 /** Property value */
54 char *name;
55 /** Format, may be 8, 16 or 32 */
56 ubyte format;
57 }
58 
59 /**
60  * @brief Deliver a GetProperty request to the X server.
61  * @param c The connection to the X server.
62  * @param window Window X identifier.
63  * @param property Property atom to get.
64  * @return The request cookie.
65  *
66  * Allow to get a window property, in most case you might want to use
67  * above functions to get an ICCCM property for a given window.
68  */
69 xcb_get_property_cookie_t xcb_icccm_get_text_property(xcb_connection_t *c,
70                                                         xcb_window_t window,
71                                                         xcb_atom_t property);
72 
73 /**
74  * @see xcb_icccm_get_text_property()
75  */
76 xcb_get_property_cookie_t xcb_icccm_get_text_property_unchecked(xcb_connection_t *c,
77                                                                   xcb_window_t window,
78                                                                   xcb_atom_t property);
79 
80 /**
81  * @brief Fill given structure with the property value of a window.
82  * @param c The connection to the X server.
83  * @param cookie TextProperty request cookie.
84  * @param prop TextProperty reply which is to be filled.
85  * @param e Error if any.
86  * @return Return 1 on success, 0 otherwise.
87  *
88  * If the function return 0 (failure), the content of prop is unmodified and
89  * therefore the structure must not be wiped.
90  *
91  * The parameter e supplied to this function must be NULL if
92  * xcb_icccm_get_text_property_unchecked() is used.  Otherwise, it stores
93  * the error if any.  prop structure members should be freed by
94  * xcb_icccm_get_text_property_reply_wipe().
95  */
96 ubyte xcb_icccm_get_text_property_reply(xcb_connection_t *c,
97                                             xcb_get_property_cookie_t cookie,
98                                             xcb_icccm_get_text_property_reply_t *prop,
99                                             xcb_generic_error_t **e);
100 
101 /**
102  * @brief Wipe prop structure members previously allocated by
103  *        xcb_icccm_get_text_property_reply().
104  * @param prop prop structure whose members is going to be freed.
105  */
106 void xcb_icccm_get_text_property_reply_wipe(xcb_icccm_get_text_property_reply_t *prop);
107 
108 /* WM_NAME */
109 
110 /**
111  * @brief Deliver a SetProperty request to set WM_NAME property value.
112  * @param c The connection to the X server.
113  * @param window Window X identifier.
114  * @param encoding Encoding used for the data passed in the name parameter, the set property will also have this encoding as its type.
115  * @param format Encoding format.
116  * @param name_len Length of name value to set.
117  * @param name Name value to set.
118  */
119 xcb_void_cookie_t xcb_icccm_set_wm_name_checked(xcb_connection_t *c,
120                                                   xcb_window_t window,
121                                                   xcb_atom_t encoding,
122                                                   ubyte format,
123                                                   uint name_len,
124                                                   const(char) *name);
125 
126 /**
127  * @see xcb_icccm_set_wm_name_checked()
128  */
129 xcb_void_cookie_t xcb_icccm_set_wm_name(xcb_connection_t *c, xcb_window_t window,
130                                           xcb_atom_t encoding, ubyte format,
131                                           uint name_len, const(char) *name);
132 
133 /**
134  * @brief Deliver a GetProperty request to the X server for WM_NAME.
135  * @param c The connection to the X server.
136  * @param window Window X identifier.
137  * @return The request cookie.
138  */
139 xcb_get_property_cookie_t xcb_icccm_get_wm_name(xcb_connection_t *c,
140                                                   xcb_window_t window);
141 
142 /**
143  * @see xcb_icccm_get_wm_name()
144  */
145 xcb_get_property_cookie_t xcb_icccm_get_wm_name_unchecked(xcb_connection_t *c,
146                                                             xcb_window_t window);
147 
148 /**
149  * @brief Fill given structure with the WM_NAME property of a window.
150  * @param c The connection to the X server.
151  * @param cookie Request cookie.
152  * @param prop WM_NAME property value.
153  * @param e Error if any.
154  * @see xcb_icccm_get_text_property_reply()
155  * @return Return 1 on success, 0 otherwise.
156  */
157 ubyte xcb_icccm_get_wm_name_reply(xcb_connection_t *c,
158                                       xcb_get_property_cookie_t cookie,
159                                       xcb_icccm_get_text_property_reply_t *prop,
160                                       xcb_generic_error_t **e);
161 
162 /* WM_ICON_NAME */
163 
164 /**
165  * @brief Deliver a SetProperty request to set WM_ICON_NAME property value.
166  * @param c The connection to the X server.
167  * @param window Window X identifier.
168  * @param encoding Encoding used for the data passed in the name parameter, the set property will also have this encoding as its type.
169  * @param format Encoding format.
170  * @param name_len Length of name value to set.
171  * @param name Name value to set.
172  */
173 xcb_void_cookie_t xcb_icccm_set_wm_icon_name_checked(xcb_connection_t *c,
174                                                        xcb_window_t window,
175                                                        xcb_atom_t encoding,
176                                                        ubyte format,
177                                                        uint name_len,
178                                                        const(char) *name);
179 
180 /**
181  * @see xcb_icccm_set_wm_icon_name_checked()
182  */
183 xcb_void_cookie_t xcb_icccm_set_wm_icon_name(xcb_connection_t *c,
184                                                xcb_window_t window,
185                                                xcb_atom_t encoding,
186                                                ubyte format,
187                                                uint name_len,
188                                                const(char) *name);
189 
190 /**
191  * @brief Send request to get WM_ICON_NAME property of a window.
192  * @param c The connection to the X server.
193  * @param window Window X identifier.
194  * @return The request cookie.
195  */
196 xcb_get_property_cookie_t xcb_icccm_get_wm_icon_name(xcb_connection_t *c,
197                                                        xcb_window_t window);
198 
199 /**
200  * @see xcb_icccm_get_wm_icon_name()
201  */
202 xcb_get_property_cookie_t xcb_icccm_get_wm_icon_name_unchecked(xcb_connection_t *c,
203                                                                  xcb_window_t window);
204 
205 /**
206  * @brief Fill given structure with the WM_ICON_NAME property of a window.
207  * @param c The connection to the X server.
208  * @param cookie Request cookie.
209  * @param prop WM_ICON_NAME property value.
210  * @param e Error if any.
211  * @see xcb_icccm_get_text_property_reply()
212  * @return Return 1 on success, 0 otherwise.
213  */
214 ubyte xcb_icccm_get_wm_icon_name_reply(xcb_connection_t *c,
215                                            xcb_get_property_cookie_t cookie,
216                                            xcb_icccm_get_text_property_reply_t *prop,
217                                            xcb_generic_error_t **e);
218 
219 /* WM_COLORMAP_WINDOWS */
220 
221 /**
222  * @brief Deliver a ChangeProperty request to set WM_COLORMAP_WINDOWS property value.
223  * @param c The connection to the X server.
224  * @param wm_colormap_windows The WM_COLORMAP_WINDOWS atom
225  * @param window Window X identifier.
226  * @param list_len Windows list len.
227  * @param list Windows list.
228  * @return The request cookie.
229  */
230 xcb_void_cookie_t xcb_icccm_set_wm_colormap_windows_checked(xcb_connection_t *c,
231                                                               xcb_window_t window,
232                                                               xcb_atom_t wm_colormap_windows_atom,
233                                                               uint list_len,
234                                                               const(xcb_window_t) *list);
235 
236 /**
237  * @see xcb_icccm_set_wm_colormap_windows_checked()
238  */
239 xcb_void_cookie_t xcb_icccm_set_wm_colormap_windows(xcb_connection_t *c,
240                                                       xcb_window_t window,
241                                                       xcb_atom_t wm_colormap_windows_atom,
242                                                       uint list_len,
243                                                       const(xcb_window_t) *list);
244 
245 /**
246  * @brief WM_COLORMAP_WINDOWS structure.
247  */
248 struct xcb_icccm_get_wm_colormap_windows_reply_t {
249 /** Length of the windows list */
250 uint windows_len;
251 /** Windows list */
252 xcb_window_t *windows;
253 /** Store reply to avoid memory allocation, should normally not be
254     used directly */
255 xcb_get_property_reply_t *_reply;
256 }
257 
258 /**
259  * @brief Send request to get WM_COLORMAP_WINDOWS property of a given window.
260  * @param c The connection to the X server.
261  * @param window Window X identifier.
262  * @return The request cookie.
263  */
264 xcb_get_property_cookie_t xcb_icccm_get_wm_colormap_windows(xcb_connection_t *c,
265                                                               xcb_window_t window,
266                                                               xcb_atom_t wm_colormap_windows_atom);
267 
268 /**
269  * @see xcb_icccm_get_wm_colormap_windows()
270  */
271 xcb_get_property_cookie_t xcb_icccm_get_wm_colormap_windows_unchecked(xcb_connection_t *c,
272                                                                         xcb_window_t window,
273                                                                         xcb_atom_t wm_colormap_windows_atom);
274 
275 /**
276  * @brief Fill the given structure with the WM_COLORMAP_WINDOWS property of a window.
277  * @param reply The reply of the GetProperty request.
278  * @param colormap_windows WM_COLORMAP property value.
279  * @return Return 1 on success, 0 otherwise.
280  *
281  * protocols structure members should be freed by
282  * xcb_icccm_get_wm_protocols_reply_wipe().
283  */
284 ubyte xcb_icccm_get_wm_colormap_windows_from_reply(xcb_get_property_reply_t *reply,
285                                                        xcb_icccm_get_wm_colormap_windows_reply_t *colormap_windows);
286 /**
287  * @brief Fill the given structure with the WM_COLORMAP_WINDOWS property of a window.
288  * @param c The connection to the X server.
289  * @param cookie Request cookie.
290  * @param protocols WM_COLORMAP_WINDOWS property value.
291  * @param e Error if any.
292  * @return Return 1 on success, 0 otherwise.
293  *
294  * The parameter e supplied to this function must be NULL if
295  * xcb_icccm_get_wm_colormap_windows_unchecked() is used.  Otherwise, it
296  * stores the error if any. protocols structure members should be
297  * freed by xcb_icccm_get_wm_colormap_windows_reply_wipe().
298  */
299 ubyte xcb_icccm_get_wm_colormap_windows_reply(xcb_connection_t *c,
300                                                   xcb_get_property_cookie_t cookie,
301                                                   xcb_icccm_get_wm_colormap_windows_reply_t *windows,
302                                                   xcb_generic_error_t **e);
303 
304 /**
305  * @brief Wipe protocols structure members previously allocated by
306  *        xcb_icccm_get_wm_colormap_windows_reply().
307  * @param windows windows structure whose members is going to be freed.
308  */
309 void xcb_icccm_get_wm_colormap_windows_reply_wipe(xcb_icccm_get_wm_colormap_windows_reply_t *windows);
310 
311 /* WM_CLIENT_MACHINE */
312 
313 /**
314  * @brief Deliver a SetProperty request to set WM_CLIENT_MACHINE property value.
315  * @param c The connection to the X server.
316  * @param window Window X identifier.
317  * @param encoding Encoding used for the data passed in the name parameter, the set property will also have this encoding as its type.
318  * @param format Encoding format.
319  * @param name_len Length of name value to set.
320  * @param name Name value to set.
321  */
322 xcb_void_cookie_t xcb_icccm_set_wm_client_machine_checked(xcb_connection_t *c,
323                                                             xcb_window_t window,
324                                                             xcb_atom_t encoding,
325                                                             ubyte format,
326                                                             uint name_len,
327                                                             const(char) *name);
328 
329 /**
330  * @see xcb_icccm_set_wm_client_machine_checked()
331  */
332 xcb_void_cookie_t xcb_icccm_set_wm_client_machine(xcb_connection_t *c,
333                                                     xcb_window_t window,
334                                                     xcb_atom_t encoding,
335                                                     ubyte format,
336                                                     uint name_len,
337                                                     const(char) *name);
338 
339 /**
340  * @brief Send request to get WM_CLIENT_MACHINE property of a window.
341  * @param c The connection to the X server.
342  * @param window Window X identifier.
343  * @return The request cookie.
344  */
345 xcb_get_property_cookie_t xcb_icccm_get_wm_client_machine(xcb_connection_t *c,
346                                                             xcb_window_t window);
347 
348 /**
349  * @see xcb_icccm_get_wm_client_machine()
350  */
351 xcb_get_property_cookie_t xcb_icccm_get_wm_client_machine_unchecked(xcb_connection_t *c,
352                                                                       xcb_window_t window);
353 
354 /**
355  * @brief Fill given structure with the WM_CLIENT_MACHINE property of a window.
356  * @param c The connection to the X server.
357  * @param cookie Request cookie.
358  * @param prop WM_CLIENT_MACHINE property value.
359  * @param e Error if any.
360  * @see xcb_icccm_get_text_property_reply()
361  * @return Return 1 on success, 0 otherwise.
362  */
363 ubyte xcb_icccm_get_wm_client_machine_reply(xcb_connection_t *c,
364                                                 xcb_get_property_cookie_t cookie,
365                                                 xcb_icccm_get_text_property_reply_t *prop,
366                                                 xcb_generic_error_t **e);
367 
368 /* WM_CLASS */
369 
370 /**
371  * @brief WM_CLASS hint structure
372  */
373 
374 /**
375  * @brief Deliver a SetProperty request to set WM_CLASS property value.
376  *
377  * WM_CLASS string is a concatenation of the instance and class name
378  * strings respectively (including null character).
379  *
380  * @param c The connection to the X server.
381  * @param window Window X identifier.
382  * @param class_len Length of WM_CLASS string.
383  * @param class_name WM_CLASS string.
384  * @return The request cookie.
385  */
386 xcb_void_cookie_t xcb_icccm_set_wm_class_checked(xcb_connection_t *c,
387                                                    xcb_window_t window,
388                                                    uint class_len,
389                                                    const(char) *class_name);
390 
391 /**
392  * @see xcb_icccm_set_wm_class_checked()
393  */
394 xcb_void_cookie_t xcb_icccm_set_wm_class(xcb_connection_t *c,
395                                            xcb_window_t window,
396                                            uint class_len,
397                                            const char *class_name);
398 
399 struct xcb_icccm_get_wm_class_reply_t {
400 /** Instance name */
401 char *instance_name;
402 /** Class of application */
403 char *class_name;
404 /** Store reply to avoid memory allocation, should normally not be
405     used directly */
406 xcb_get_property_reply_t *_reply;
407 }
408 
409 /**
410  * @brief Deliver a GetProperty request to the X server for WM_CLASS.
411  * @param c The connection to the X server.
412  * @param window Window X identifier.
413  * @return The request cookie.
414  */
415 xcb_get_property_cookie_t xcb_icccm_get_wm_class(xcb_connection_t *c,
416                                                    xcb_window_t window);
417 
418 /**
419  * @see xcb_icccm_get_wm_class()
420  */
421 xcb_get_property_cookie_t xcb_icccm_get_wm_class_unchecked(xcb_connection_t *c,
422                                                              xcb_window_t window);
423 
424 
425 /**
426  * @brief Fill give structure with the WM_CLASS property of a window.
427  * @param prop The property structure to fill.
428  * @param reply The property request reply.
429  * @return Return 1 on success, 0 otherwise.
430  */
431 ubyte
432 xcb_icccm_get_wm_class_from_reply(xcb_icccm_get_wm_class_reply_t *prop,
433                                     xcb_get_property_reply_t *reply);
434 
435 /**
436  * @brief Fill given structure with the WM_CLASS property of a window.
437  * @param c The connection to the X server.
438  * @param cookie Request cookie.
439  * @param prop WM_CLASS property value.
440  * @param e Error if any.
441  * @return Return 1 on success, 0 otherwise.
442  *
443  * The parameter e supplied to this function must be NULL if
444  * xcb_icccm_get_wm_class_unchecked() is used.  Otherwise, it stores the
445  * error if any. prop structure members should be freed by
446  * xcb_icccm_get_wm_class_reply_wipe().
447  */
448 ubyte xcb_icccm_get_wm_class_reply(xcb_connection_t *c,
449                                        xcb_get_property_cookie_t cookie,
450                                        xcb_icccm_get_wm_class_reply_t *prop,
451                                        xcb_generic_error_t **e);
452 
453 /**
454  * @brief Wipe prop structure members previously allocated by
455  *        xcb_icccm_get_wm_class_reply().
456  * @param prop prop structure whose members is going to be freed.
457  */
458 void xcb_icccm_get_wm_class_reply_wipe(xcb_icccm_get_wm_class_reply_t *prop);
459 
460 /* WM_TRANSIENT_FOR */
461 
462 /**
463  * @brief Deliver a SetProperty request to set WM_TRANSIENT_FOR property value.
464  * @param c The connection to the X server.
465  * @param window Window X identifier.
466  * @param transient_for_window The WM_TRANSIENT_FOR window X identifier.
467  * @return The request cookie.
468  */
469 xcb_void_cookie_t xcb_icccm_set_wm_transient_for_checked(xcb_connection_t *c,
470                                                            xcb_window_t window,
471                                                            xcb_window_t transient_for_window);
472 
473 /**
474  * @see xcb_icccm_set_wm_transient_for
475  */
476 xcb_void_cookie_t xcb_icccm_set_wm_transient_for(xcb_connection_t *c,
477                                                    xcb_window_t window,
478                                                    xcb_window_t transient_for_window);
479 
480 /**
481  * @brief Send request to get WM_TRANSIENT_FOR property of a window.
482  * @param c The connection to the X server
483  * @param window Window X identifier.
484  * @return The request cookie.
485  */
486 xcb_get_property_cookie_t xcb_icccm_get_wm_transient_for(xcb_connection_t *c,
487                                                            xcb_window_t window);
488 
489 /**
490  * @see xcb_icccm_get_wm_transient_for_unchecked()
491  */
492 xcb_get_property_cookie_t xcb_icccm_get_wm_transient_for_unchecked(xcb_connection_t *c,
493                                                                      xcb_window_t window);
494 
495 /**
496  * @brief Fill given window pointer with the WM_TRANSIENT_FOR property of a window.
497  * @param prop WM_TRANSIENT_FOR property value.
498  * @param reply The get property request reply.
499  * @return Return 1 on success, 0 otherwise.
500  */
501 ubyte
502 xcb_icccm_get_wm_transient_for_from_reply(xcb_window_t *prop,
503                                             xcb_get_property_reply_t *reply);
504 /**
505  * @brief Fill given structure with the WM_TRANSIENT_FOR property of a window.
506  * @param c The connection to the X server.
507  * @param cookie Request cookie.
508  * @param prop WM_TRANSIENT_FOR property value.
509  * @param e Error if any.
510  * @return Return 1 on success, 0 otherwise.
511  *
512  * The parameter e supplied to this function must be NULL if
513  * xcb_icccm_get_wm_transient_for_unchecked() is used.  Otherwise, it stores
514  * the error if any.
515  */
516 ubyte xcb_icccm_get_wm_transient_for_reply(xcb_connection_t *c,
517                                                xcb_get_property_cookie_t cookie,
518                                                xcb_window_t *prop,
519                                                xcb_generic_error_t **e);
520 
521 /* WM_SIZE_HINTS */
522 
523 enum xcb_icccm_size_hints_flags_t {
524   XCB_ICCCM_SIZE_HINT_US_POSITION = 1 << 0,
525   XCB_ICCCM_SIZE_HINT_US_SIZE = 1 << 1,
526   XCB_ICCCM_SIZE_HINT_P_POSITION = 1 << 2,
527   XCB_ICCCM_SIZE_HINT_P_SIZE = 1 << 3,
528   XCB_ICCCM_SIZE_HINT_P_MIN_SIZE = 1 << 4,
529   XCB_ICCCM_SIZE_HINT_P_MAX_SIZE = 1 << 5,
530   XCB_ICCCM_SIZE_HINT_P_RESIZE_INC = 1 << 6,
531   XCB_ICCCM_SIZE_HINT_P_ASPECT = 1 << 7,
532   XCB_ICCCM_SIZE_HINT_BASE_SIZE = 1 << 8,
533   XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY = 1 << 9
534 }
535 alias XCB_ICCCM_SIZE_HINT_US_POSITION = xcb_icccm_size_hints_flags_t.XCB_ICCCM_SIZE_HINT_US_POSITION;
536 alias XCB_ICCCM_SIZE_HINT_US_SIZE = xcb_icccm_size_hints_flags_t.XCB_ICCCM_SIZE_HINT_US_SIZE;
537 alias XCB_ICCCM_SIZE_HINT_P_POSITION = xcb_icccm_size_hints_flags_t.XCB_ICCCM_SIZE_HINT_P_POSITION;
538 alias XCB_ICCCM_SIZE_HINT_P_SIZE = xcb_icccm_size_hints_flags_t.XCB_ICCCM_SIZE_HINT_P_SIZE;
539 alias XCB_ICCCM_SIZE_HINT_P_MIN_SIZE = xcb_icccm_size_hints_flags_t.XCB_ICCCM_SIZE_HINT_P_MIN_SIZE;
540 alias XCB_ICCCM_SIZE_HINT_P_MAX_SIZE = xcb_icccm_size_hints_flags_t.XCB_ICCCM_SIZE_HINT_P_MAX_SIZE;
541 alias XCB_ICCCM_SIZE_HINT_P_RESIZE_INC = xcb_icccm_size_hints_flags_t.XCB_ICCCM_SIZE_HINT_P_RESIZE_INC;
542 alias XCB_ICCCM_SIZE_HINT_P_ASPECT = xcb_icccm_size_hints_flags_t.XCB_ICCCM_SIZE_HINT_P_ASPECT;
543 alias XCB_ICCCM_SIZE_HINT_BASE_SIZE = xcb_icccm_size_hints_flags_t.XCB_ICCCM_SIZE_HINT_BASE_SIZE;
544 alias XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY = xcb_icccm_size_hints_flags_t.XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY;
545 
546 /**
547  * @brief Size hints structure.
548  */
549 struct xcb_size_hints_t {
550 /** User specified flags */
551 uint flags;
552 /** User-specified position */
553 int x, y;
554 /** User-specified size */
555 int width, height;
556 /** Program-specified minimum size */
557 int min_width, min_height;
558 /** Program-specified maximum size */
559 int max_width, max_height;
560 /** Program-specified resize increments */
561 int width_inc, height_inc;
562 /** Program-specified minimum aspect ratios */
563 int min_aspect_num, min_aspect_den;
564 /** Program-specified maximum aspect ratios */
565 int max_aspect_num, max_aspect_den;
566 /** Program-specified base size */
567 int base_width, base_height;
568 /** Program-specified window gravity */
569 uint win_gravity;
570 }
571 
572 /** Number of elements in this structure */
573 enum XCB_ICCCM_NUM_WM_SIZE_HINTS_ELEMENTS = 18;
574 
575 /**
576  * @brief Set size hints to a given position.
577  * @param hints SIZE_HINTS structure.
578  * @param user_specified Is the size user-specified?
579  * @param x The X position.
580  * @param y The Y position.
581  */
582 void xcb_icccm_size_hints_set_position(xcb_size_hints_t *hints, int user_specified,
583                                          int x, int y);
584 
585 /**
586  * @brief Set size hints to a given size.
587  * @param hints SIZE_HINTS structure.
588  * @param user_specified is the size user-specified?
589  * @param width The width.
590  * @param height The height.
591  */
592 void xcb_icccm_size_hints_set_size(xcb_size_hints_t *hints, int user_specified,
593                                      int width, int height);
594 
595 /**
596  * @brief Set size hints to a given minimum size.
597  * @param hints SIZE_HINTS structure.
598  * @param width The minimum width.
599  * @param height The minimum height.
600  */
601 void xcb_icccm_size_hints_set_min_size(xcb_size_hints_t *hints, int min_width,
602                                          int min_height);
603 
604 /**
605  * @brief Set size hints to a given maximum size.
606  * @param hints SIZE_HINTS structure.
607  * @param width The maximum width.
608  * @param height The maximum height.
609  */
610 void xcb_icccm_size_hints_set_max_size(xcb_size_hints_t *hints, int max_width,
611                                          int max_height);
612 
613 /**
614  * @brief Set size hints to a given resize increments.
615  * @param hints SIZE_HINTS structure.
616  * @param width The resize increments width.
617  * @param height The resize increments height.
618  */
619 void xcb_icccm_size_hints_set_resize_inc(xcb_size_hints_t *hints, int width_inc,
620                                            int height_inc);
621 
622 /**
623  * @brief Set size hints to a given aspect ratios.
624  * @param hints SIZE_HINTS structure.
625  * @param min_aspect_num The minimum aspect ratios for the width.
626  * @param min_aspect_den The minimum aspect ratios for the height.
627  * @param max_aspect_num The maximum aspect ratios for the width.
628  * @param max_aspect_den The maximum aspect ratios for the height.
629  */
630 void xcb_icccm_size_hints_set_aspect(xcb_size_hints_t *hints, int min_aspect_num,
631                                        int min_aspect_den, int max_aspect_num,
632                                      int max_aspect_den);
633 
634 /**
635  * @brief Set size hints to a given base size.
636  * @param hints SIZE_HINTS structure.
637  * @param base_width Base width.
638  * @param base_height Base height.
639  */
640 void xcb_icccm_size_hints_set_base_size(xcb_size_hints_t *hints, int base_width,
641                                           int base_height);
642 
643 /**
644  * @brief Set size hints to a given window gravity.
645  * @param hints SIZE_HINTS structure.
646  * @param win_gravity Window gravity value.
647  */
648 void xcb_icccm_size_hints_set_win_gravity(xcb_size_hints_t *hints,
649                                             xcb_gravity_t win_gravity);
650 
651 /**
652  * @brief Deliver a ChangeProperty request to set a value to a given property.
653  * @param c The connection to the X server.
654  * @param window Window X identifier.
655  * @param property Property to set value for.
656  * @param hints Hints value to set.
657  */
658 xcb_void_cookie_t xcb_icccm_set_wm_size_hints_checked(xcb_connection_t *c,
659                                                         xcb_window_t window,
660                                                       xcb_atom_t property,
661                                                       xcb_size_hints_t *hints);
662 
663 /**
664  * @see xcb_icccm_set_wm_size_hints_checked()
665  */
666 xcb_void_cookie_t xcb_icccm_set_wm_size_hints(xcb_connection_t *c,
667                                                 xcb_window_t window,
668                                               xcb_atom_t property,
669                                               xcb_size_hints_t *hints);
670 
671 /**
672  * @brief Send request to get size hints structure for the named property.
673  * @param c The connection to the X server.
674  * @param window Window X identifier.
675  * @param property Specify the property name.
676  * @return The request cookie.
677  */
678 xcb_get_property_cookie_t xcb_icccm_get_wm_size_hints(xcb_connection_t *c,
679                                                         xcb_window_t window,
680                                                       xcb_atom_t property);
681 
682 /**
683  * @see xcb_icccm_get_wm_size_hints()
684  */
685 xcb_get_property_cookie_t xcb_icccm_get_wm_size_hints_unchecked(xcb_connection_t *c,
686                                                                   xcb_window_t window,
687                                                                 xcb_atom_t property);
688 
689 /**
690  * @brief Fill given structure with the size hints of the named property.
691  * @param c The connection to the X server.
692  * @param cookie Request cookie.
693  * @param hints Size hints structure.
694  * @param e Error if any.
695  * @return Return 1 on success, 0 otherwise.
696  *
697  * The parameter e supplied to this function must be NULL if
698  * xcb_icccm_get_wm_size_hints_unchecked() is used.  Otherwise, it stores
699  * the error if any. The returned pointer should be freed.
700  */
701 ubyte xcb_icccm_get_wm_size_hints_reply(xcb_connection_t *c,
702                                             xcb_get_property_cookie_t cookie,
703                                           xcb_size_hints_t *hints,
704                                           xcb_generic_error_t **e);
705 
706 /* WM_NORMAL_HINTS */
707 
708 /**
709  * @brief Deliver a ChangeProperty request to set WM_NORMAL_HINTS property value.
710  * @param c The connection to the X server.
711  * @param window Window X identifier.
712  * @param hints Hints value to set.
713  */
714 xcb_void_cookie_t xcb_icccm_set_wm_normal_hints_checked(xcb_connection_t *c,
715                                                           xcb_window_t window,
716                                                         xcb_size_hints_t *hints);
717 
718 /**
719  * @see xcb_icccm_set_wm_normal_hints_checked()
720  */
721 xcb_void_cookie_t xcb_icccm_set_wm_normal_hints(xcb_connection_t *c,
722                                                   xcb_window_t window,
723                                                 xcb_size_hints_t *hints);
724 
725 /**
726  * @brief Send request to get WM_NORMAL_HINTS property of a window.
727  * @param c The connection to the X server.
728  * @param window Window X identifier.
729  * @return The request cookie.
730  */
731 xcb_get_property_cookie_t xcb_icccm_get_wm_normal_hints(xcb_connection_t *c,
732                                                           xcb_window_t window);
733 
734 /**
735  * @see xcb_icccm_get_wm_normal_hints()
736  */
737 xcb_get_property_cookie_t xcb_icccm_get_wm_normal_hints_unchecked(xcb_connection_t *c,
738                                                                     xcb_window_t window);
739 
740 /**
741  * @brief Fill given structure with the WM_NORMAL_HINTS property of a window.
742  * @param hints WM_NORMAL_HINTS property value.
743  * @param reply The get property request reply.
744  * @return Return 1 on success, 0 otherwise.
745  */
746 ubyte
747 xcb_icccm_get_wm_size_hints_from_reply(xcb_size_hints_t *hints,
748                                          xcb_get_property_reply_t *reply);
749 
750 /**
751  * @brief Fill given structure with the WM_NORMAL_HINTS property of a window.
752  * @param c The connection to the X server.
753  * @param cookie Request cookie.
754  * @param hints WM_NORMAL_HINTS property value.
755  * @param e Error if any.
756  * @return Return 1 on success, 0 otherwise.
757  *
758  * The parameter e supplied to this function must be NULL if
759  * xcb_icccm_get_wm_normal_hints_unchecked() is used.  Otherwise, it stores
760  * the error if any. The returned pointer should be freed.
761  */
762 ubyte xcb_icccm_get_wm_normal_hints_reply(xcb_connection_t *c,
763                                               xcb_get_property_cookie_t cookie,
764                                             xcb_size_hints_t *hints,
765                                             xcb_generic_error_t **e);
766 
767 /* WM_HINTS */
768 
769 /**
770  * @brief WM hints structure (may be extended in the future).
771  */
772 struct xcb_icccm_wm_hints_t {
773 /** Marks which fields in this structure are defined */
774 int flags;
775 /** Does this application rely on the window manager to get keyboard
776     input? */
777   uint input;
778   /** See below */
779   int initial_state;
780   /** Pixmap to be used as icon */
781   xcb_pixmap_t icon_pixmap;
782   /** Window to be used as icon */
783   xcb_window_t icon_window;
784   /** Initial position of icon */
785   int icon_x, icon_y;
786   /** Icon mask bitmap */
787   xcb_pixmap_t icon_mask;
788   /* Identifier of related window group */
789   xcb_window_t window_group;
790 }
791 
792 /** Number of elements in this structure */
793 enum XCB_ICCCM_NUM_WM_HINTS_ELEMENTS = 9;
794 
795 /**
796  * @brief WM_HINTS window states.
797  */
798 enum xcb_icccm_wm_state_t {
799   XCB_ICCCM_WM_STATE_WITHDRAWN = 0,
800   XCB_ICCCM_WM_STATE_NORMAL = 1,
801   XCB_ICCCM_WM_STATE_ICONIC = 3
802 }
803 alias XCB_ICCCM_WM_STATE_WITHDRAWN = xcb_icccm_wm_state_t.XCB_ICCCM_WM_STATE_WITHDRAWN;
804 alias XCB_ICCCM_WM_STATE_NORMAL = xcb_icccm_wm_state_t.XCB_ICCCM_WM_STATE_NORMAL;
805 alias XCB_ICCCM_WM_STATE_ICONIC = xcb_icccm_wm_state_t.XCB_ICCCM_WM_STATE_ICONIC;
806 
807 enum xcb_icccm_wm_t {
808   XCB_ICCCM_WM_HINT_INPUT = (1L << 0),
809   XCB_ICCCM_WM_HINT_STATE = (1L << 1),
810   XCB_ICCCM_WM_HINT_ICON_PIXMAP = (1L << 2),
811   XCB_ICCCM_WM_HINT_ICON_WINDOW = (1L << 3),
812   XCB_ICCCM_WM_HINT_ICON_POSITION = (1L << 4),
813   XCB_ICCCM_WM_HINT_ICON_MASK = (1L << 5),
814   XCB_ICCCM_WM_HINT_WINDOW_GROUP = (1L << 6),
815   XCB_ICCCM_WM_HINT_X_URGENCY = (1L << 8)
816 }
817 alias XCB_ICCCM_WM_HINT_INPUT = xcb_icccm_wm_t.XCB_ICCCM_WM_HINT_INPUT;
818 alias XCB_ICCCM_WM_HINT_STATE = xcb_icccm_wm_t.XCB_ICCCM_WM_HINT_STATE;
819 alias XCB_ICCCM_WM_HINT_ICON_PIXMAP = xcb_icccm_wm_t.XCB_ICCCM_WM_HINT_ICON_PIXMAP;
820 alias XCB_ICCCM_WM_HINT_ICON_WINDOW = xcb_icccm_wm_t.XCB_ICCCM_WM_HINT_ICON_WINDOW;
821 alias XCB_ICCCM_WM_HINT_ICON_POSITION = xcb_icccm_wm_t.XCB_ICCCM_WM_HINT_ICON_POSITION;
822 alias XCB_ICCCM_WM_HINT_ICON_MASK = xcb_icccm_wm_t.XCB_ICCCM_WM_HINT_ICON_MASK;
823 alias XCB_ICCCM_WM_HINT_WINDOW_GROUP = xcb_icccm_wm_t.XCB_ICCCM_WM_HINT_WINDOW_GROUP;
824 alias XCB_ICCCM_WM_HINT_X_URGENCY = xcb_icccm_wm_t.XCB_ICCCM_WM_HINT_X_URGENCY;
825 
826 enum XCB_ICCCM_WM_ALL_HINTS = XCB_ICCCM_WM_HINT_INPUT | XCB_ICCCM_WM_HINT_STATE |
827                               XCB_ICCCM_WM_HINT_ICON_PIXMAP | XCB_ICCCM_WM_HINT_ICON_WINDOW |
828                               XCB_ICCCM_WM_HINT_ICON_POSITION | XCB_ICCCM_WM_HINT_ICON_MASK |
829                               XCB_ICCCM_WM_HINT_WINDOW_GROUP;
830 
831 /**
832  * @brief Get urgency hint.
833  * @param hints WM_HINTS structure.
834  * @return Urgency hint value.
835  */
836 uint xcb_icccm_wm_hints_get_urgency(xcb_icccm_wm_hints_t *hints);
837 
838 /**
839  * @brief Set input focus.
840  * @param hints WM_HINTS structure.
841  * @param input Input focus.
842  */
843 void xcb_icccm_wm_hints_set_input(xcb_icccm_wm_hints_t *hints, ubyte input);
844 
845 /**
846  * @brief Set hints state to 'iconic'.
847  * @param hints WM_HINTS structure.
848  */
849 void xcb_icccm_wm_hints_set_iconic(xcb_icccm_wm_hints_t *hints);
850 
851 /**
852  * @brief Set hints state to 'normal'.
853  * @param hints WM_HINTS structure.
854  */
855 void xcb_icccm_wm_hints_set_normal(xcb_icccm_wm_hints_t *hints);
856 
857 /**
858  * @brief Set hints state to 'withdrawn'.
859  * @param hints WM_HINTS structure.
860  */
861 void xcb_icccm_wm_hints_set_withdrawn(xcb_icccm_wm_hints_t *hints);
862 
863 /**
864  * @brief Set hints state to none.
865  * @param hints WM_HINTS structure.
866  */
867 void xcb_icccm_wm_hints_set_none(xcb_icccm_wm_hints_t *hints);
868 
869 /**
870  * @brief Set pixmap to be used as icon.
871  * @param hints WM_HINTS structure.
872  * @param icon_pixmap Pixmap.
873  */
874 void xcb_icccm_wm_hints_set_icon_pixmap(xcb_icccm_wm_hints_t *hints,
875                                         xcb_pixmap_t icon_pixmap);
876 
877 /**
878  * @brief Set icon mask bitmap.
879  * @param hints WM_HINTS structure.
880  * @param icon_mask Pixmap.
881  */
882 void xcb_icccm_wm_hints_set_icon_mask(xcb_icccm_wm_hints_t *hints, xcb_pixmap_t icon_mask);
883 
884 /**
885  * @brief Set window identifier to be used as icon.
886  * @param hints WM_HINTS structure.
887  * @param icon_window Window X identifier.
888  */
889 void xcb_icccm_wm_hints_set_icon_window(xcb_icccm_wm_hints_t *hints,
890                                         xcb_window_t icon_window);
891 
892 /**
893  * @brief Set identifier of related window group.
894  * @param hints WM_HINTS structure.
895  * @param window_group Window X identifier.
896  */
897 void xcb_icccm_wm_hints_set_window_group(xcb_icccm_wm_hints_t *hints,
898                                          xcb_window_t window_group);
899 
900 /**
901  * @brief Set urgency hints flag.
902  * @param hints WM_HINTS structure.
903  */
904 void xcb_icccm_wm_hints_set_urgency(xcb_icccm_wm_hints_t *hints);
905 
906 /**
907  * @brief Deliver a SetProperty request to set WM_HINTS property value.
908  * @param c The connection to the X server.
909  * @param window Window X identifier.
910  * @param hints Hints value to set.
911  */
912 xcb_void_cookie_t xcb_icccm_set_wm_hints_checked(xcb_connection_t *c,
913                                                  xcb_window_t window,
914                                                  xcb_icccm_wm_hints_t *hints);
915 
916 /**
917  * @see xcb_icccm_set_wm_hints_checked()
918  */
919 xcb_void_cookie_t xcb_icccm_set_wm_hints(xcb_connection_t *c,
920                                          xcb_window_t window,
921                                          xcb_icccm_wm_hints_t *hints);
922 
923 /**
924  * @brief Send request to get WM_HINTS property of a window.
925  * @param c The connection to the X server.
926  * @param window Window X identifier.
927  * @return The request cookie.
928  */
929 xcb_get_property_cookie_t xcb_icccm_get_wm_hints(xcb_connection_t *c,
930                                                  xcb_window_t window);
931 
932 /**
933  * @see xcb_icccm_get_wm_hints()
934  */
935 xcb_get_property_cookie_t xcb_icccm_get_wm_hints_unchecked(xcb_connection_t *c,
936                                                            xcb_window_t window);
937 
938 /**
939  * @brief Fill given structure with the WM_HINTS property of a window.
940  * @param hints WM_HINTS property value.
941  * @param reply The get property request reply.
942  * @return Return 1 on success, 0 otherwise.
943  */
944 ubyte
945 xcb_icccm_get_wm_hints_from_reply(xcb_icccm_wm_hints_t *hints,
946                                   xcb_get_property_reply_t *reply);
947 
948 /**
949  * @brief Fill given structure with the WM_HINTS property of a window.
950  * @param c The connection to the X server.
951  * @param cookie Request cookie.
952  * @param hints WM_HINTS property value.
953  * @param e Error if any.
954  * @return Return 1 on success, 0 otherwise.
955  *
956  * The parameter e supplied to this function must be NULL if
957  * xcb_icccm_get_wm_hints_unchecked() is used.  Otherwise, it stores the
958  * error if any. The returned pointer should be freed.
959  */
960 ubyte xcb_icccm_get_wm_hints_reply(xcb_connection_t *c,
961                                      xcb_get_property_cookie_t cookie,
962                                      xcb_icccm_wm_hints_t *hints,
963                                      xcb_generic_error_t **e);
964 
965 /* WM_PROTOCOLS */
966 
967 /**
968  * @brief Deliver a SetProperty request to set WM_PROTOCOLS property value.
969  * @param c The connection to the X server.
970  * @param wm_protocols The WM_PROTOCOLS atom.
971  * @param window Window X identifier.
972  * @param list_len Atom list len.
973  * @param list Atom list.
974  */
975 xcb_void_cookie_t xcb_icccm_set_wm_protocols_checked(xcb_connection_t *c,
976                                                      xcb_window_t window,
977                                                      xcb_atom_t wm_protocols,
978                                                      uint list_len,
979                                                      xcb_atom_t *list);
980 
981 /**
982  * @see xcb_icccm_set_wm_protocols_checked()
983  */
984 xcb_void_cookie_t xcb_icccm_set_wm_protocols(xcb_connection_t *c,
985                                              xcb_window_t window,
986                                              xcb_atom_t wm_protocols,
987                                              uint list_len,
988                                              xcb_atom_t *list);
989 
990 /**
991  * @brief WM_PROTOCOLS structure.
992  */
993 struct xcb_icccm_get_wm_protocols_reply_t {
994   /** Length of the atoms list */
995   uint atoms_len;
996   /** Atoms list */
997   xcb_atom_t *atoms;
998   /** Store reply to avoid memory allocation, should normally not be
999       used directly */
1000   xcb_get_property_reply_t *_reply;
1001 }
1002 
1003 /**
1004  * @brief Send request to get WM_PROTOCOLS property of a given window.
1005  * @param c The connection to the X server.
1006  * @param window Window X identifier.
1007  * @return The request cookie.
1008  */
1009 xcb_get_property_cookie_t xcb_icccm_get_wm_protocols(xcb_connection_t *c,
1010                                                      xcb_window_t window,
1011                                                      xcb_atom_t wm_protocol_atom);
1012 
1013 /**
1014  * @see xcb_icccm_get_wm_protocols()
1015  */
1016 xcb_get_property_cookie_t xcb_icccm_get_wm_protocols_unchecked(xcb_connection_t *c,
1017                                                                xcb_window_t window,
1018                                                                xcb_atom_t wm_protocol_atom);
1019 
1020 /**
1021  * @brief Fill the given structure with the WM_PROTOCOLS property of a window.
1022  * @param reply The reply of the GetProperty request.
1023  * @param protocols WM_PROTOCOLS property value.
1024  * @return Return 1 on success, 0 otherwise.
1025  *
1026  * protocols structure members should be freed by
1027  * xcb_icccm_get_wm_protocols_reply_wipe().
1028  */
1029 ubyte xcb_icccm_get_wm_protocols_from_reply(xcb_get_property_reply_t *reply,
1030                                               xcb_icccm_get_wm_protocols_reply_t *protocols);
1031 /**
1032  * @brief Fill the given structure with the WM_PROTOCOLS property of a window.
1033  * @param c The connection to the X server.
1034  * @param cookie Request cookie.
1035  * @param protocols WM_PROTOCOLS property value.
1036  * @param e Error if any.
1037  * @return Return 1 on success, 0 otherwise.
1038  *
1039  * The parameter e supplied to this function must be NULL if
1040  * xcb_icccm_get_wm_protocols_unchecked() is used.  Otherwise, it stores the
1041  * error if any. protocols structure members should be freed by
1042  * xcb_icccm_get_wm_protocols_reply_wipe().
1043  */
1044 ubyte xcb_icccm_get_wm_protocols_reply(xcb_connection_t *c,
1045                                          xcb_get_property_cookie_t cookie,
1046                                          xcb_icccm_get_wm_protocols_reply_t *protocols,
1047                                          xcb_generic_error_t **e);
1048 
1049 /**
1050  * @brief Wipe protocols structure members previously allocated by
1051  *        xcb_icccm_get_wm_protocols_reply().
1052  * @param protocols protocols structure whose members is going to be freed.
1053  */
1054 void xcb_icccm_get_wm_protocols_reply_wipe(xcb_icccm_get_wm_protocols_reply_t *protocols);
1055