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

source code of include/xcb/xcb_icccm.h