1#ifndef __XCB_ICCCM_H__
2#define __XCB_ICCCM_H__
3
4/*
5 * Copyright (C) 2008 Arnaud Fontaine <arnau@debian.org>
6 * Copyright (C) 2007-2008 Vincent Torri <vtorri@univ-evry.fr>
7 *
8 * Permission is hereby granted, free of charge, to any person
9 * obtaining a copy of this software and associated documentation
10 * files (the "Software"), to deal in the Software without
11 * restriction, including without limitation the rights to use, copy,
12 * modify, merge, publish, distribute, sublicense, and/or sell copies
13 * of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
23 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
24 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 *
27 * Except as contained in this notice, the names of the authors or
28 * their institutions shall not be used in advertising or otherwise to
29 * promote the sale, use or other dealings in this Software without
30 * prior written authorization from the authors.
31 */
32
33/**
34 * @defgroup xcb__icccm_t XCB ICCCM Functions
35 *
36 * These functions allow easy handling of the protocol described in the
37 * Inter-Client Communication Conventions Manual.
38 *
39 * @{
40 */
41
42#include <xcb/xcb.h>
43#include "xcb_property.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/**
50 * @brief TextProperty reply structure.
51 */
52typedef struct {
53  /** Store reply to avoid memory allocation, should normally not be
54      used directly */
55  xcb_get_property_reply_t *_reply;
56  /** Encoding used */
57  xcb_atom_t encoding;
58  /** Length of the name field above */
59  uint32_t name_len;
60  /** Property value */
61  char *name;
62  /** Format, may be 8, 16 or 32 */
63  uint8_t format;
64} xcb_get_text_property_reply_t;
65
66/**
67 * @brief Deliver a GetProperty request to the X server.
68 * @param c The connection to the X server.
69 * @param window Window X identifier.
70 * @param property Property atom to get.
71 * @return The request cookie.
72 *
73 * Allow to get a window property, in most case you might want to use
74 * above functions to get an ICCCM property for a given window.
75 */
76xcb_get_property_cookie_t xcb_get_text_property(xcb_connection_t *c,
77                                                xcb_window_t window,
78                                                xcb_atom_t property);
79
80/**
81 * @see xcb_get_text_property()
82 */
83xcb_get_property_cookie_t xcb_get_text_property_unchecked(xcb_connection_t *c,
84                                                          xcb_window_t window,
85                                                          xcb_atom_t property);
86
87/**
88 * @brief Fill given structure with the property value of a window.
89 * @param c The connection to the X server.
90 * @param cookie TextProperty request cookie.
91 * @param prop TextProperty reply which is to be filled.
92 * @param e Error if any.
93 * @return Return 1 on success, 0 otherwise.
94 *
95 * If the function return 0 (failure), the content of prop is unmodified and
96 * therefore the structure must not be wiped.
97 *
98 * The parameter e supplied to this function must be NULL if
99 * xcb_get_text_property_unchecked() is used.  Otherwise, it stores
100 * the error if any.  prop structure members should be freed by
101 * xcb_get_text_property_reply_wipe().
102 */
103uint8_t xcb_get_text_property_reply(xcb_connection_t *c,
104                                    xcb_get_property_cookie_t cookie,
105                                    xcb_get_text_property_reply_t *prop,
106                                    xcb_generic_error_t **e);
107
108/**
109 * @brief Wipe prop structure members previously allocated by
110 *        xcb_get_text_property_reply().
111 * @param prop prop structure whose members is going to be freed.
112 */
113void xcb_get_text_property_reply_wipe(xcb_get_text_property_reply_t *prop);
114
115/* WM_NAME */
116
117/**
118 * @brief Deliver a SetProperty request to set WM_NAME property value.
119 * @param c The connection to the X server.
120 * @param window Window X identifier.
121 * @param encoding Encoding used for the data passed in the name parameter, the set property will also have this encoding as its type.
122 * @param name_len Length of name value to set.
123 * @param name Name value to set.
124 */
125void xcb_set_wm_name_checked(xcb_connection_t *c,
126                             xcb_window_t window,
127                             xcb_atom_t encoding,
128                             uint32_t name_len,
129                             const char *name);
130
131/**
132 * @see xcb_set_wm_name_checked()
133 */
134void xcb_set_wm_name(xcb_connection_t *c, xcb_window_t window,
135                     xcb_atom_t encoding, uint32_t name_len,
136                     const char *name);
137
138/**
139 * @brief Deliver a GetProperty request to the X server for WM_NAME.
140 * @param c The connection to the X server.
141 * @param window Window X identifier.
142 * @return The request cookie.
143 */
144xcb_get_property_cookie_t xcb_get_wm_name(xcb_connection_t *c,
145                                          xcb_window_t window);
146
147/**
148 * @see xcb_get_wm_name()
149 */
150xcb_get_property_cookie_t xcb_get_wm_name_unchecked(xcb_connection_t *c,
151                                                    xcb_window_t window);
152
153/**
154 * @brief Fill given structure with the WM_NAME property of a window.
155 * @param c The connection to the X server.
156 * @param cookie Request cookie.
157 * @param prop WM_NAME property value.
158 * @param e Error if any.
159 * @see xcb_get_text_property_reply()
160 * @return Return 1 on success, 0 otherwise.
161 */
162uint8_t xcb_get_wm_name_reply(xcb_connection_t *c,
163                              xcb_get_property_cookie_t cookie,
164                              xcb_get_text_property_reply_t *prop,
165                              xcb_generic_error_t **e);
166
167/**
168 * @brief Set a callback on WM_NAME property changes.
169 * @param prophs Property handlers.
170 * @param long_len Length of data.
171 * @param handler The callback.
172 * @param data data given to the callback.
173 */
174void xcb_watch_wm_name(xcb_property_handlers_t *prophs, uint32_t long_len,
175                       xcb_generic_property_handler_t handler, void *data);
176
177/* WM_ICON_NAME */
178
179/**
180 * @brief Deliver a SetProperty request to set WM_ICON_NAME property value.
181 * @param c The connection to the X server.
182 * @param window Window X identifier.
183 * @param encoding Encoding used for the data passed in the name parameter, the set property will also have this encoding as its type.
184 * @param name_len Length of name value to set.
185 * @param name Name value to set.
186 */
187void xcb_set_wm_icon_name_checked(xcb_connection_t *c, xcb_window_t window,
188                                  xcb_atom_t encoding, uint32_t name_len,
189                                  const char *name);
190
191/**
192 * @see xcb_set_wm_icon_name_checked()
193 */
194void xcb_set_wm_icon_name(xcb_connection_t *c, xcb_window_t window,
195                          xcb_atom_t encoding, uint32_t name_len,
196                          const char *name);
197
198/**
199 * @brief Send request to get WM_ICON_NAME property of a window.
200 * @param c The connection to the X server.
201 * @param window Window X identifier.
202 * @return The request cookie.
203 */
204xcb_get_property_cookie_t xcb_get_wm_icon_name(xcb_connection_t *c,
205                                               xcb_window_t window);
206
207/**
208  * @see xcb_get_wm_icon_name()
209  */
210xcb_get_property_cookie_t xcb_get_wm_icon_name_unchecked(xcb_connection_t *c,
211                                                         xcb_window_t window);
212
213/**
214 * @brief Fill given structure with the WM_ICON_NAME property of a window.
215 * @param c The connection to the X server.
216 * @param cookie Request cookie.
217 * @param prop WM_ICON_NAME property value.
218 * @param e Error if any.
219 * @see xcb_get_text_property_reply()
220 * @return Return 1 on success, 0 otherwise.
221 */
222uint8_t xcb_get_wm_icon_name_reply(xcb_connection_t *c,
223                                   xcb_get_property_cookie_t cookie,
224                                   xcb_get_text_property_reply_t *prop,
225                                   xcb_generic_error_t **e);
226
227/**
228 * @brief Set a callback on WM_ICON_NAME property changes.
229 * @param prophs Property handlers.
230 * @param long_len Length of data.
231 * @param handler The callback.
232 * @param data data given to the callback.
233 */
234void xcb_watch_wm_icon_name(xcb_property_handlers_t *prophs, uint32_t long_len,
235                            xcb_generic_property_handler_t handler,
236                            void *data);
237
238/* WM_CLIENT_MACHINE */
239
240/**
241 * @brief Deliver a SetProperty request to set WM_CLIENT_MACHINE property value.
242 * @param c The connection to the X server.
243 * @param window Window X identifier.
244 * @param encoding Encoding used for the data passed in the name parameter, the set property will also have this encoding as its type.
245 * @param name_len Length of name value to set.
246 * @param name Name value to set.
247 */
248void xcb_set_wm_client_machine_checked(xcb_connection_t *c, xcb_window_t window,
249                                       xcb_atom_t encoding, uint32_t name_len,
250                                       const char *name);
251
252/**
253 * @see xcb_set_wm_client_machine_checked()
254 */
255void xcb_set_wm_client_machine(xcb_connection_t *c, xcb_window_t window,
256                               xcb_atom_t encoding, uint32_t name_len,
257                               const char *name);
258
259/**
260 * @brief Send request to get WM_CLIENT_MACHINE property of a window.
261 * @param c The connection to the X server.
262 * @param window Window X identifier.
263 * @return The request cookie.
264 */
265xcb_get_property_cookie_t xcb_get_wm_client_machine(xcb_connection_t *c,
266                                                    xcb_window_t window);
267
268/**
269 * @see xcb_get_wm_client_machine()
270 */
271xcb_get_property_cookie_t xcb_get_wm_client_machine_unchecked(xcb_connection_t *c,
272                                                              xcb_window_t window);
273
274/**
275 * @brief Fill given structure with the WM_CLIENT_MACHINE property of a window.
276 * @param c The connection to the X server.
277 * @param cookie Request cookie.
278 * @param prop WM_CLIENT_MACHINE property value.
279 * @param e Error if any.
280 * @see xcb_get_text_property_reply()
281 * @return Return 1 on success, 0 otherwise.
282 */
283uint8_t xcb_get_wm_client_machine_reply(xcb_connection_t *c,
284                                        xcb_get_property_cookie_t cookie,
285                                        xcb_get_text_property_reply_t *prop,
286                                        xcb_generic_error_t **e);
287
288/**
289 * @brief Set a callback on WM_CLIENT_MACHINE property changes.
290 * @param prophs Property handlers.
291 * @param long_len Length of data.
292 * @param handler The callback.
293 * @param data data given to the callback.
294 */
295void xcb_watch_wm_client_machine(xcb_property_handlers_t *prophs,
296                                 uint32_t long_len,
297                                 xcb_generic_property_handler_t handler,
298                                 void *data);
299
300/* WM_CLASS */
301
302/**
303 * @brief WM_CLASS hint structure
304 */
305typedef struct {
306  /** Instance name */
307  char *instance_name;
308  /** Class of application */
309  char *class_name;
310  /** Store reply to avoid memory allocation, should normally not be
311      used directly */
312  xcb_get_property_reply_t *_reply;
313} xcb_get_wm_class_reply_t;
314
315/**
316 * @brief Deliver a GetProperty request to the X server for WM_CLASS.
317 * @param c The connection to the X server.
318 * @param window Window X identifier.
319 * @return The request cookie.
320 */
321xcb_get_property_cookie_t xcb_get_wm_class(xcb_connection_t *c,
322                                           xcb_window_t window);
323
324/**
325 * @see xcb_get_wm_class()
326 */
327xcb_get_property_cookie_t xcb_get_wm_class_unchecked(xcb_connection_t *c,
328                                                     xcb_window_t window);
329
330
331/**
332 * @brief Fill give structure with the WM_CLASS property of a window.
333 * @param prop The property structur to fill.
334 * @param reply The property request reply.
335 * @return Return 1 on success, 0 otherwise.
336 */
337uint8_t
338xcb_get_wm_class_from_reply(xcb_get_wm_class_reply_t *prop,
339                            xcb_get_property_reply_t *reply);
340
341/**
342 * @brief Fill given structure with the WM_CLASS property of a window.
343 * @param c The connection to the X server.
344 * @param cookie Request cookie.
345 * @param prop WM_CLASS property value.
346 * @param e Error if any.
347 * @return Return 1 on success, 0 otherwise.
348 *
349 * The parameter e supplied to this function must be NULL if
350 * xcb_get_wm_class_unchecked() is used.  Otherwise, it stores the
351 * error if any. prop structure members should be freed by
352 * xcb_get_wm_class_reply_wipe().
353 */
354uint8_t xcb_get_wm_class_reply(xcb_connection_t *c,
355                               xcb_get_property_cookie_t cookie,
356                               xcb_get_wm_class_reply_t *prop,
357                               xcb_generic_error_t **e);
358
359/**
360 * @brief Wipe prop structure members previously allocated by
361 *        xcb_get_wm_class_reply().
362 * @param prop prop structure whose members is going to be freed.
363 */
364void xcb_get_wm_class_reply_wipe(xcb_get_wm_class_reply_t *prop);
365
366/* WM_TRANSIENT_FOR */
367
368/**
369 * @brief Send request to get WM_TRANSIENT_FOR property of a window.
370 * @param c The connection to the X server
371 * @param window Window X identifier.
372 * @return The request cookie.
373 */
374xcb_get_property_cookie_t xcb_get_wm_transient_for(xcb_connection_t *c,
375                                                   xcb_window_t window);
376
377/**
378 * @see xcb_get_wm_transient_for_unchecked()
379 */
380xcb_get_property_cookie_t xcb_get_wm_transient_for_unchecked(xcb_connection_t *c,
381                                                             xcb_window_t window);
382
383/**
384 * @brief Fill given window pointer with the WM_TRANSIENT_FOR property of a window.
385 * @param prop WM_TRANSIENT_FOR property value.
386 * @param reply The get property request reply.
387 * @return Return 1 on success, 0 otherwise.
388 */
389uint8_t
390xcb_get_wm_transient_for_from_reply(xcb_window_t *prop,
391                                    xcb_get_property_reply_t *reply);
392/**
393 * @brief Fill given structure with the WM_TRANSIENT_FOR property of a window.
394 * @param c The connection to the X server.
395 * @param cookie Request cookie.
396 * @param prop WM_TRANSIENT_FOR property value.
397 * @param e Error if any.
398 * @return Return 1 on success, 0 otherwise.
399 *
400 * The parameter e supplied to this function must be NULL if
401 * xcb_get_wm_transient_for_unchecked() is used.  Otherwise, it stores
402 * the error if any.
403 */
404uint8_t xcb_get_wm_transient_for_reply(xcb_connection_t *c,
405                                       xcb_get_property_cookie_t cookie,
406                                       xcb_window_t *prop,
407                                       xcb_generic_error_t **e);
408
409/* WM_SIZE_HINTS */
410
411typedef enum {
412  XCB_SIZE_HINT_US_POSITION = 1 << 0,
413  XCB_SIZE_HINT_US_SIZE = 1 << 1,
414  XCB_SIZE_HINT_P_POSITION = 1 << 2,
415  XCB_SIZE_HINT_P_SIZE = 1 << 3,
416  XCB_SIZE_HINT_P_MIN_SIZE = 1 << 4,
417  XCB_SIZE_HINT_P_MAX_SIZE = 1 << 5,
418  XCB_SIZE_HINT_P_RESIZE_INC = 1 << 6,
419  XCB_SIZE_HINT_P_ASPECT = 1 << 7,
420  XCB_SIZE_HINT_BASE_SIZE = 1 << 8,
421  XCB_SIZE_HINT_P_WIN_GRAVITY = 1 << 9
422} xcb_size_hints_flags_t;
423
424/**
425 * @brief Size hints structure.
426 */
427typedef struct {
428  /** User specified flags */
429  uint32_t flags;
430  /** User-specified position */
431  int32_t x, y;
432  /** User-specified size */
433  int32_t width, height;
434  /** Program-specified minimum size */
435  int32_t min_width, min_height;
436  /** Program-specified maximum size */
437  int32_t max_width, max_height;
438  /** Program-specified resize increments */
439  int32_t width_inc, height_inc;
440  /** Program-specified minimum aspect ratios */
441  int32_t min_aspect_num, min_aspect_den;
442  /** Program-specified maximum aspect ratios */
443  int32_t max_aspect_num, max_aspect_den;
444  /** Program-specified base size */
445  int32_t base_width, base_height;
446  /** Program-specified window gravity */
447  uint32_t win_gravity;
448} xcb_size_hints_t;
449
450/**
451 * @brief Set size hints to a given position.
452 * @param hints SIZE_HINTS structure.
453 * @param user_specified Is the size user-specified?
454 * @param x The X position.
455 * @param y The Y position.
456 */
457void xcb_size_hints_set_position(xcb_size_hints_t *hints, int user_specified,
458                                 int32_t x, int32_t y);
459
460/**
461 * @brief Set size hints to a given size.
462 * @param hints SIZE_HINTS structure.
463 * @param user_specified is the size user-specified?
464 * @param width The width.
465 * @param height The height.
466 */
467void xcb_size_hints_set_size(xcb_size_hints_t *hints, int user_specified,
468                             int32_t width, int32_t height);
469
470/**
471 * @brief Set size hints to a given minimum size.
472 * @param hints SIZE_HINTS structure.
473 * @param width The minimum width.
474 * @param height The minimum height.
475 */
476void xcb_size_hints_set_min_size(xcb_size_hints_t *hints, int32_t min_width,
477                                 int32_t min_height);
478
479/**
480 * @brief Set size hints to a given maximum size.
481 * @param hints SIZE_HINTS structure.
482 * @param width The maximum width.
483 * @param height The maximum height.
484 */
485void xcb_size_hints_set_max_size(xcb_size_hints_t *hints, int32_t max_width,
486                                 int32_t max_height);
487
488/**
489 * @brief Set size hints to a given resize increments.
490 * @param hints SIZE_HINTS structure.
491 * @param width The resize increments width.
492 * @param height The resize increments height.
493 */
494void xcb_size_hints_set_resize_inc(xcb_size_hints_t *hints, int32_t width_inc,
495                                   int32_t height_inc);
496
497/**
498 * @brief Set size hints to a given aspect ratios.
499 * @param hints SIZE_HINTS structure.
500 * @param min_aspect_num The minimum aspect ratios for the width.
501 * @param min_aspect_den The minimum aspect ratios for the height.
502 * @param max_aspect_num The maximum aspect ratios for the width.
503 * @param max_aspect_den The maximum aspect ratios for the height.
504 */
505void xcb_size_hints_set_aspect(xcb_size_hints_t *hints, int32_t min_aspect_num,
506                               int32_t min_aspect_den, int32_t max_aspect_num,
507                               int32_t max_aspect_den);
508
509/**
510 * @brief Set size hints to a given base size.
511 * @param hints SIZE_HINTS structure.
512 * @param base_width Base width.
513 * @param base_height Base height.
514 */
515void xcb_size_hints_set_base_size(xcb_size_hints_t *hints, int32_t base_width,
516                                  int32_t base_height);
517
518/**
519 * @brief Set size hints to a given window gravity.
520 * @param hints SIZE_HINTS structure.
521 * @param win_gravity Window gravity value.
522 */
523void xcb_size_hints_set_win_gravity(xcb_size_hints_t *hints,
524                                    xcb_gravity_t win_gravity);
525
526/**
527 * @brief Deliver a ChangeProperty request to set a value to a given property.
528 * @param c The connection to the X server.
529 * @param window Window X identifier.
530 * @param property Property to set value for.
531 * @param hints Hints value to set.
532 */
533void xcb_set_wm_size_hints_checked(xcb_connection_t *c, xcb_window_t window,
534                                   xcb_atom_t property, xcb_size_hints_t *hints);
535
536/**
537 * @see xcb_set_wm_size_hints_checked()
538 */
539void xcb_set_wm_size_hints(xcb_connection_t *c, xcb_window_t window,
540                           xcb_atom_t property, xcb_size_hints_t *hints);
541
542/**
543 * @brief Send request to get size hints structure for the named property.
544 * @param c The connection to the X server.
545 * @param window Window X identifier.
546 * @param property Specify the property name.
547 * @return The request cookie.
548 */
549xcb_get_property_cookie_t xcb_get_wm_size_hints(xcb_connection_t *c,
550                                                xcb_window_t window,
551                                                xcb_atom_t property);
552
553/**
554 * @see xcb_get_wm_size_hints()
555 */
556xcb_get_property_cookie_t xcb_get_wm_size_hints_unchecked(xcb_connection_t *c,
557                                                          xcb_window_t window,
558                                                          xcb_atom_t property);
559
560/**
561 * @brief Fill given structure with the size hints of the named property.
562 * @param c The connection to the X server.
563 * @param cookie Request cookie.
564 * @param hints Size hints structure.
565 * @param e Error if any.
566 * @return Return 1 on success, 0 otherwise.
567 *
568 * The parameter e supplied to this function must be NULL if
569 * xcb_get_wm_size_hints_unchecked() is used.  Otherwise, it stores
570 * the error if any. The returned pointer should be freed.
571 */
572uint8_t xcb_get_wm_size_hints_reply(xcb_connection_t *c,
573                                    xcb_get_property_cookie_t cookie,
574                                    xcb_size_hints_t *hints,
575                                    xcb_generic_error_t **e);
576
577/* WM_NORMAL_HINTS */
578
579/**
580 * @brief Deliver a ChangeProperty request to set WM_NORMAL_HINTS property value.
581 * @param c The connection to the X server.
582 * @param window Window X identifier.
583 * @param hints Hints value to set.
584 */
585void xcb_set_wm_normal_hints_checked(xcb_connection_t *c, xcb_window_t window,
586                                     xcb_size_hints_t *hints);
587
588/**
589 * @see xcb_set_wm_normal_hints_checked()
590 */
591void xcb_set_wm_normal_hints(xcb_connection_t *c, xcb_window_t window,
592                             xcb_size_hints_t *hints);
593
594/**
595 * @brief Send request to get WM_NORMAL_HINTS property of a window.
596 * @param c The connection to the X server.
597 * @param window Window X identifier.
598 * @return The request cookie.
599 */
600xcb_get_property_cookie_t xcb_get_wm_normal_hints(xcb_connection_t *c,
601                                                  xcb_window_t window);
602
603/**
604 * @see xcb_get_wm_normal_hints()
605 */
606xcb_get_property_cookie_t xcb_get_wm_normal_hints_unchecked(xcb_connection_t *c,
607                                                            xcb_window_t window);
608
609/**
610 * @brief Fill given structure with the WM_NORMAL_HINTS property of a window.
611 * @param hints WM_NORMAL_HINTS property value.
612 * @param reply The get property request reply.
613 * @return Return 1 on success, 0 otherwise.
614 */
615uint8_t
616xcb_get_wm_size_hints_from_reply(xcb_size_hints_t *hints,
617                                 xcb_get_property_reply_t *reply);
618
619/**
620 * @brief Fill given structure with the WM_NORMAL_HINTS property of a window.
621 * @param c The connection to the X server.
622 * @param cookie Request cookie.
623 * @param hints WM_NORMAL_HINTS property value.
624 * @param e Error if any.
625 * @return Return 1 on success, 0 otherwise.
626 *
627 * The parameter e supplied to this function must be NULL if
628 * xcb_get_wm_normal_hints_unchecked() is used.  Otherwise, it stores
629 * the error if any. The returned pointer should be freed.
630 */
631uint8_t xcb_get_wm_normal_hints_reply(xcb_connection_t *c,
632                                      xcb_get_property_cookie_t cookie,
633                                      xcb_size_hints_t *hints,
634                                      xcb_generic_error_t **e);
635
636/* WM_HINTS */
637
638/**
639 * @brief WM hints structure (may be extended in the future).
640 */
641typedef struct {
642  /** Marks which fields in this structure are defined */
643  int32_t flags;
644  /** Does this application rely on the window manager to get keyboard
645      input? */
646  uint32_t input;
647  /** See below */
648  int32_t initial_state;
649  /** Pixmap to be used as icon */
650  xcb_pixmap_t icon_pixmap;
651  /** Window to be used as icon */
652  xcb_window_t icon_window;
653  /** Initial position of icon */
654  int32_t icon_x, icon_y;
655  /** Icon mask bitmap */
656  xcb_pixmap_t icon_mask;
657  /* Identifier of related window group */
658  xcb_window_t window_group;
659} xcb_wm_hints_t;
660
661/** Number of elements in this structure */
662#define XCB_NUM_WM_HINTS_ELEMENTS 9
663
664/**
665 * @brief WM_HINTS window states.
666 */
667typedef enum {
668  XCB_WM_STATE_WITHDRAWN = 0,
669  XCB_WM_STATE_NORMAL = 1,
670  XCB_WM_STATE_ICONIC = 3
671} xcb_wm_state_t;
672
673typedef enum {
674  XCB_WM_HINT_INPUT = (1L << 0),
675  XCB_WM_HINT_STATE = (1L << 1),
676  XCB_WM_HINT_ICON_PIXMAP = (1L << 2),
677  XCB_WM_HINT_ICON_WINDOW = (1L << 3),
678  XCB_WM_HINT_ICON_POSITION = (1L << 4),
679  XCB_WM_HINT_ICON_MASK = (1L << 5),
680  XCB_WM_HINT_WINDOW_GROUP = (1L << 6),
681  XCB_WM_HINT_X_URGENCY = (1L << 8)
682} xcb_wm_t;
683
684#define XCB_WM_ALL_HINTS (XCB_WM_HINT_INPUT | XCB_WM_HINT_STATE |\
685                          XCB_WM_HINT_ICON_PIXMAP | XCB_WM_HINT_ICON_WINDOW |\
686                          XCB_WM_HINT_ICON_POSITION | XCB_WM_HINT_ICON_MASK |\
687                          XCB_WM_HINT_WINDOW_GROUP)
688
689/**
690 * @brief Get urgency hint.
691 * @param hints WM_HINTS structure.
692 * @return Urgency hint value.
693 */
694uint32_t xcb_wm_hints_get_urgency(xcb_wm_hints_t *hints);
695
696/**
697 * @brief Set input focus.
698 * @param hints WM_HINTS structure.
699 * @param input Input focus.
700 */
701void xcb_wm_hints_set_input(xcb_wm_hints_t *hints, uint8_t input);
702
703/**
704 * @brief Set hints state to 'iconic'.
705 * @param hints WM_HINTS structure.
706 */
707void xcb_wm_hints_set_iconic(xcb_wm_hints_t *hints);
708
709/**
710 * @brief Set hints state to 'normal'.
711 * @param hints WM_HINTS structure.
712 */
713void xcb_wm_hints_set_normal(xcb_wm_hints_t *hints);
714
715/**
716 * @brief Set hints state to 'withdrawn'.
717 * @param hints WM_HINTS structure.
718 */
719void xcb_wm_hints_set_withdrawn(xcb_wm_hints_t *hints);
720
721/**
722 * @brief Set hints state to none.
723 * @param hints WM_HINTS structure.
724 */
725void xcb_wm_hints_set_none(xcb_wm_hints_t *hints);
726
727/**
728 * @brief Set pixmap to be used as icon.
729 * @param hints WM_HINTS structure.
730 * @param icon_pixmap Pixmap.
731 */
732void xcb_wm_hints_set_icon_pixmap(xcb_wm_hints_t *hints,
733                                  xcb_pixmap_t icon_pixmap);
734
735/**
736 * @brief Set icon mask bitmap.
737 * @param hints WM_HINTS structure.
738 * @param icon_mask Pixmap.
739 */
740void xcb_wm_hints_set_icon_mask(xcb_wm_hints_t *hints, xcb_pixmap_t icon_mask);
741
742/**
743 * @brief Set window identifier to be used as icon.
744 * @param hints WM_HINTS structure.
745 * @param icon_window Window X identifier.
746 */
747void xcb_wm_hints_set_icon_window(xcb_wm_hints_t *hints,
748                                  xcb_window_t icon_window);
749
750/**
751 * @brief Set identifier of related window group.
752 * @param hints WM_HINTS structure.
753 * @param window_group Window X identifier.
754 */
755void xcb_wm_hints_set_window_group(xcb_wm_hints_t *hints,
756                                   xcb_window_t window_group);
757
758/**
759 * @brief Set urgency hints flag.
760 * @param hints WM_HINTS structure.
761 */
762void xcb_wm_hints_set_urgency(xcb_wm_hints_t *hints);
763
764/**
765 * @brief Deliver a SetProperty request to set WM_HINTS property value.
766 * @param c The connection to the X server.
767 * @param window Window X identifier.
768 * @param hints Hints value to set.
769 */
770void xcb_set_wm_hints_checked(xcb_connection_t *c, xcb_window_t window,
771                              xcb_wm_hints_t *hints);
772
773/**
774 * @see xcb_set_wm_hints_checked()
775 */
776void xcb_set_wm_hints(xcb_connection_t *c, xcb_window_t window,
777                      xcb_wm_hints_t *hints);
778
779/**
780 * @brief Send request to get WM_HINTS property of a window.
781 * @param c The connection to the X server.
782 * @param window Window X identifier.
783 * @return The request cookie.
784 */
785xcb_get_property_cookie_t xcb_get_wm_hints(xcb_connection_t *c,
786                                           xcb_window_t window);
787
788/**
789 * @see xcb_get_wm_hints()
790 */
791xcb_get_property_cookie_t xcb_get_wm_hints_unchecked(xcb_connection_t *c,
792                                                     xcb_window_t window);
793
794/**
795 * @brief Fill given structure with the WM_HINTS property of a window.
796 * @param hints WM_HINTS property value.
797 * @param reply The get property request reply.
798 * @return Return 1 on success, 0 otherwise.
799 */
800uint8_t
801xcb_get_wm_hints_from_reply(xcb_wm_hints_t *hints,
802                            xcb_get_property_reply_t *reply);
803
804/**
805 * @brief Fill given structure with the WM_HINTS property of a window.
806 * @param c The connection to the X server.
807 * @param cookie Request cookie.
808 * @param hints WM_HINTS property value.
809 * @param e Error if any.
810 * @return Return 1 on success, 0 otherwise.
811 *
812 * The parameter e supplied to this function must be NULL if
813 * xcb_get_wm_hints_unchecked() is used.  Otherwise, it stores the
814 * error if any. The returned pointer should be freed.
815 */
816uint8_t xcb_get_wm_hints_reply(xcb_connection_t *c,
817                               xcb_get_property_cookie_t cookie,
818                               xcb_wm_hints_t *hints,
819                               xcb_generic_error_t **e);
820
821/* WM_PROTOCOLS */
822
823/**
824 * @brief Deliver a SetProperty request to set WM_PROTOCOLS property value.
825 * @param c The connection to the X server.
826 * @param wm_protocols The WM_PROTOCOLS atom.
827 * @param window Window X identifier.
828 * @param list_len Atom list len.
829 * @param list Atom list.
830 */
831void xcb_set_wm_protocols_checked(xcb_connection_t *c, xcb_atom_t wm_protocols,
832                                  xcb_window_t window, uint32_t list_len,
833                                  xcb_atom_t *list);
834
835/**
836 * @see xcb_set_wm_protocols_checked()
837 */
838void xcb_set_wm_protocols(xcb_connection_t *c, xcb_atom_t wm_protocols,
839                          xcb_window_t window, uint32_t list_len,
840                          xcb_atom_t *list);
841
842/**
843 * @brief WM_PROTOCOLS structure.
844 */
845typedef struct {
846  /** Length of the atoms list */
847  uint32_t atoms_len;
848  /** Atoms list */
849  xcb_atom_t *atoms;
850  /** Store reply to avoid memory allocation, should normally not be
851      used directly */
852  xcb_get_property_reply_t *_reply;
853} xcb_get_wm_protocols_reply_t;
854
855/**
856 * @brief Send request to get WM_PROTOCOLS property of a given window.
857 * @param c The connection to the X server.
858 * @param window Window X identifier.
859 * @return The request cookie.
860 */
861xcb_get_property_cookie_t xcb_get_wm_protocols(xcb_connection_t *c,
862                                               xcb_window_t window,
863                                               xcb_atom_t wm_protocol_atom);
864
865/**
866 * @see xcb_get_wm_protocols()
867 */
868xcb_get_property_cookie_t xcb_get_wm_protocols_unchecked(xcb_connection_t *c,
869                                                         xcb_window_t window,
870                                                         xcb_atom_t wm_protocol_atom);
871
872/**
873 * @brief Fill the given structure with the WM_PROTOCOLS property of a window.
874 * @param reply The reply of the GetProperty request.
875 * @param protocols WM_PROTOCOLS property value.
876 * @return Return 1 on success, 0 otherwise.
877 *
878 * protocols structure members should be freed by
879 * xcb_get_wm_protocols_reply_wipe().
880 */
881uint8_t xcb_get_wm_protocols_from_reply(xcb_get_property_reply_t *reply,
882                                        xcb_get_wm_protocols_reply_t *protocols);
883/**
884 * @brief Fill the given structure with the WM_PROTOCOLS property of a window.
885 * @param c The connection to the X server.
886 * @param cookie Request cookie.
887 * @param protocols WM_PROTOCOLS property value.
888 * @param e Error if any.
889 * @return Return 1 on success, 0 otherwise.
890 *
891 * The parameter e supplied to this function must be NULL if
892 * xcb_get_wm_protocols_unchecked() is used.  Otherwise, it stores the
893 * error if any. protocols structure members should be freed by
894 * xcb_get_wm_protocols_reply_wipe().
895 */
896uint8_t xcb_get_wm_protocols_reply(xcb_connection_t *c,
897                                   xcb_get_property_cookie_t cookie,
898                                   xcb_get_wm_protocols_reply_t *protocols,
899                                   xcb_generic_error_t **e);
900
901/**
902 * @brief Wipe protocols structure members previously allocated by
903 *        xcb_get_wm_protocols_reply().
904 * @param protocols protocols structure whose members is going to be freed.
905 */
906void xcb_get_wm_protocols_reply_wipe(xcb_get_wm_protocols_reply_t *protocols);
907
908#ifdef __cplusplus
909}
910#endif
911
912/**
913 * @}
914 */
915
916#endif /* __XCB_ICCCM_H__ */
917