1xcb_get_property(3)              XCB Requests              xcb_get_property(3)
2
3
4

NAME

6       xcb_get_property - Gets a window property
7

SYNOPSIS

9       #include <xcb/xproto.h>
10
11   Request function
12       xcb_get_property_cookie_t xcb_get_property(xcb_connection_t *conn,
13              uint8_t _delete, xcb_window_t window, xcb_atom_t property,
14              xcb_atom_t type, uint32_t long_offset, uint32_t long_length);
15
16   Reply datastructure
17       typedef struct xcb_get_property_reply_t {
18           uint8_t    response_type;
19           uint8_t    format;
20           uint16_t   sequence;
21           uint32_t   length;
22           xcb_atom_t type;
23           uint32_t   bytes_after;
24           uint32_t   value_len;
25           uint8_t    pad0[12];
26       } xcb_get_property_reply_t;
27
28   Reply function
29       xcb_get_property_reply_t
30              *xcb_get_property_reply(xcb_connection_t *conn,
31              xcb_get_property_cookie_t cookie, xcb_generic_error_t **e);
32
33   Reply accessors
34       void *xcb_get_property_value(const xcb_get_property_request_t *reply);
35
36       int xcb_get_property_value_length(const xcb_get_property_reply_t
37              *reply);
38
39       xcb_generic_iterator_t xcb_get_property_value_end(const
40              xcb_get_property_reply_t *reply);
41

REQUEST ARGUMENTS

43       conn      The XCB connection to X11.
44
45       _delete   Whether the property should actually be deleted. For deleting
46                 a property, the specified type has to match the actual prop‐
47                 erty type.
48
49       window    The window whose property you want to get.
50
51       property  The property you want to get (an atom).
52
53       type      The type of the property you want to get (an atom).
54
55       long_offset
56                 Specifies the offset (in 32-bit multiples) in the specified
57                 property where the data is to be retrieved.
58
59       long_length
60                 Specifies how many 32-bit multiples of data should be re‐
61                 trieved (e.g. if you set long_length to 4, you will receive
62                 16 bytes of data).
63

REPLY FIELDS

65       response_type
66                 The type of this reply, in this case XCB_GET_PROPERTY. This
67                 field is also present in the xcb_generic_reply_t and can be
68                 used to tell replies apart from each other.
69
70       sequence  The sequence number of the last request processed by the X11
71                 server.
72
73       length    The length of the reply, in words (a word is 4 bytes).
74
75       format    Specifies whether the data should be viewed as a list of
76                 8-bit, 16-bit, or 32-bit quantities. Possible values are 8,
77                 16, and 32. This information allows the X server to correctly
78                 perform byte-swap operations as necessary.
79
80       type      The actual type of the property (an atom).
81
82       bytes_after
83                 The number of bytes remaining to be read in the property if a
84                 partial read was performed.
85
86       value_len The length of value. You should use the corresponding acces‐
87                 sor instead of this field.
88

DESCRIPTION

90       Gets the specified property from the specified window. Properties are
91       for example the window title (WM_NAME) or its minimum size (WM_NOR‐
92       MAL_HINTS).  Protocols such as EWMH also use properties - for example
93       EWMH defines the window title, encoded as UTF-8 string, in the
94       _NET_WM_NAME property.
95
96       TODO: talk about type
97
98       TODO: talk about delete
99
100       TODO: talk about the offset/length thing. what's a valid use case?
101

RETURN VALUE

103       Returns an xcb_get_property_cookie_t. Errors have to be handled when
104       calling the reply function xcb_get_property_reply.
105
106       If you want to handle errors in the event loop instead, use
107       xcb_get_property_unchecked. See xcb-requests(3) for details.
108

ERRORS

110       xcb_atom_error_t
111                 property or type do not refer to a valid atom.
112
113       xcb_value_error_t
114                 The specified long_offset is beyond the actual property
115                 length (e.g. the property has a length of 3 bytes and you are
116                 setting long_offset to 1, resulting in a byte offset of 4).
117
118       xcb_window_error_t
119                 The specified window does not exist.
120

EXAMPLE

122       /*
123        * Prints the WM_NAME property of the window.
124        *
125        */
126       void my_example(xcb_connection_t *c, xcb_window_t window) {
127           xcb_get_property_cookie_t cookie;
128           xcb_get_property_reply_t *reply;
129
130           /* These atoms are predefined in the X11 protocol. */
131           xcb_atom_t property = XCB_ATOM_WM_NAME;
132           xcb_atom_t type = XCB_ATOM_STRING;
133
134           // TODO: a reasonable long_length for WM_NAME?
135           cookie = xcb_get_property(c, 0, window, property, type, 0, 0);
136           if ((reply = xcb_get_property_reply(c, cookie, NULL))) {
137               int len = xcb_get_property_value_length(reply);
138               if (len == 0) {
139                   printf("TODO\n");
140                   free(reply);
141                   return;
142               }
143               printf("WM_NAME is %.*s\n", len,
144                      (char*)xcb_get_property_value(reply));
145           }
146           free(reply);
147       }
148

SEE ALSO

150       xcb-requests(3), xcb-examples(3), xcb_intern_atom(3), xprop(1)
151

AUTHOR

153       Generated from xproto.xml. Contact xcb@lists.freedesktop.org for cor‐
154       rections and improvements.
155
156
157
158X Version 11                      libxcb 1.13              xcb_get_property(3)
Impressum