xcb_get_property(3) | XCB Requests | xcb_get_property(3) |
xcb_get_property - Gets a window property
#include <xcb/xproto.h>
xcb_get_property_cookie_t xcb_get_property(xcb_connection_t *conn, uint8_t _delete, xcb_window_t window, xcb_atom_t property, xcb_atom_t type, uint32_t long_offset, uint32_t long_length);
typedef struct xcb_get_property_reply_t {
uint8_t response_type;
uint8_t format;
uint16_t sequence;
uint32_t length;
xcb_atom_t type;
uint32_t bytes_after;
uint32_t value_len;
uint8_t pad0[12]; } xcb_get_property_reply_t;
xcb_get_property_reply_t *xcb_get_property_reply(xcb_connection_t *conn, xcb_get_property_cookie_t cookie, xcb_generic_error_t **e);
void *xcb_get_property_value(const xcb_get_property_request_t *reply);
int xcb_get_property_value_length(const xcb_get_property_reply_t *reply);
xcb_generic_iterator_t xcb_get_property_value_end(const
xcb_get_property_reply_t *reply);
Gets the specified property from the specified window. Properties are for example the window title (WM_NAME) or its minimum size (WM_NORMAL_HINTS). Protocols such as EWMH also use properties - for example EWMH defines the window title, encoded as UTF-8 string, in the _NET_WM_NAME property.
TODO: talk about type
TODO: talk about delete
TODO: talk about the offset/length thing. what's a valid use case?
Returns an xcb_get_property_cookie_t. Errors have to be handled when calling the reply function xcb_get_property_reply.
If you want to handle errors in the event loop instead, use xcb_get_property_unchecked. See xcb-requests(3) for details.
/*
* Prints the WM_NAME property of the window.
*
*/ void my_example(xcb_connection_t *c, xcb_window_t window) {
xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply;
/* These atoms are predefined in the X11 protocol. */
xcb_atom_t property = XCB_ATOM_WM_NAME;
xcb_atom_t type = XCB_ATOM_STRING;
// TODO: a reasonable long_length for WM_NAME?
cookie = xcb_get_property(c, 0, window, property, type, 0, 0);
if ((reply = xcb_get_property_reply(c, cookie, NULL))) {
int len = xcb_get_property_value_length(reply);
if (len == 0) {
printf("TODO\n");
free(reply);
return;
}
printf("WM_NAME is %.*s\n", len,
(char*)xcb_get_property_value(reply));
}
free(reply); }
xcb-requests(3), xcb-examples(3), xcb_intern_atom(3), xprop(1)
Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements.
libxcb 1.15 | X Version 11 |