Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

xcb_intern_atom(3) [centos man page]

xcb_intern_atom(3)						   XCB Requests 						xcb_intern_atom(3)

NAME
xcb_intern_atom - Get atom identifier by name SYNOPSIS
#include <xcb/xproto.h> Request function xcb_intern_atom_cookie_t xcb_intern_atom(xcb_connection_t *conn, uint8_t only_if_exists, uint16_t name_len, const char *name); Reply datastructure typedef struct xcb_intern_atom_reply_t { uint8_t response_type; uint8_t pad0; uint16_t sequence; uint32_t length; xcb_atom_t atom; } xcb_intern_atom_reply_t; Reply function xcb_intern_atom_reply_t *xcb_intern_atom_reply(xcb_connection_t *conn, xcb_intern_atom_cookie_t cookie, xcb_generic_error_t **e); REQUEST ARGUMENTS
conn The XCB connection to X11. only_if_exists Return a valid atom id only if the atom already exists. name_len The length of the following name. name The name of the atom. REPLY FIELDS
response_type The type of this reply, in this case XCB_INTERN_ATOM. This field is also present in the xcb_generic_reply_t and can be used to tell replies apart from each other. sequence The sequence number of the last request processed by the X11 server. length The length of the reply, in words (a word is 4 bytes). atom TODO: NOT YET DOCUMENTED. DESCRIPTION
Retrieves the identifier (xcb_atom_t TODO) for the atom with the specified name. Atoms are used in protocols like EWMH, for example to store window titles (_NET_WM_NAME atom) as property of a window. If only_if_exists is 0, the atom will be created if it does not already exist. If only_if_exists is 1, XCB_ATOM_NONE will be returned if the atom does not yet exist. RETURN VALUE
Returns an xcb_intern_atom_cookie_t. Errors have to be handled when calling the reply function xcb_intern_atom_reply. If you want to handle errors in the event loop instead, use xcb_intern_atom_unchecked. See xcb-requests(3) for details. ERRORS
xcb_alloc_error_t TODO: reasons? xcb_value_error_t A value other than 0 or 1 was specified for only_if_exists. EXAMPLE
/* * Resolves the _NET_WM_NAME atom. * */ void my_example(xcb_connection *c) { xcb_intern_atom_cookie_t cookie; xcb_intern_atom_reply_t *reply; cookie = xcb_intern_atom(c, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME"); /* ... do other work here if possible ... */ if ((reply = xcb_intern_atom_reply(c, cookie, NULL))) { printf("The _NET_WM_NAME atom has ID %u0, reply->atom); free(reply); } } SEE ALSO
xcb-requests(3), xcb-examples(3), xcb_get_atom_name(3), xlsatoms(1) AUTHOR
Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements. XCB
2014-06-10 xcb_intern_atom(3)

Check Out this Related Man Page

xcb-requests(3) 						   XCB examples 						   xcb-requests(3)

NAME
xcb-requests - about request manpages DESCRIPTION
Every request in X11, like MapWindow, corresponds to a number of functions and data structures in XCB. For MapWindow, XCB provides the function xcb_map_window, which fills the xcb_map_window_request_t data structure and writes that to the X11 connection. Since the MapWindow request does not have a reply, this is the most simple case. REPLIES
Many requests have replies. For each reply, XCB provides at least a corresponding data structure and a function to return a pointer to a filled data structure. Let's take the InternAtom request as an example: XCB provides the xcb_intern_atom_reply_t data structure and xcb_intern_atom_reply function. For replies which are more complex (for example lists, such as in xcb_list_fonts), accessor functions are provided. COOKIES
XCB returns a cookie for each request you send. This is an XCB-specific data structure containing the sequence number with which the request was sent to the X11 server. To get any reply, you have to provide that cookie (so that XCB knows which of the waiting replies you want). Here is an example to illustrate the use of cookies: void my_example(xcb_connection *conn) { xcb_intern_atom_cookie_t cookie; xcb_intern_atom_reply_t *reply; cookie = xcb_intern_atom(conn, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME"); /* ... do other work here if possible ... */ if ((reply = xcb_intern_atom_reply(conn, cookie, NULL))) { printf("The _NET_WM_NAME atom has ID %u0, reply->atom); } free(reply); } CHECKED VS. UNCHECKED The checked and unchecked suffixes for functions determine which kind of error handling is used for this specific request. For requests which have no reply (for example xcb_map_window), errors will be delivered to the event loop (you will receive an X11 event of type 0 when calling xcb_poll_for_event). If you want to explicitly check for errors in a blocking fashion, call the _checked version of the function (for example xcb_map_window_checked) and use xcb_request_check. For requests which have a reply (for example xcb_intern_atom), errors will be checked when calling the reply function. To get errors in the event loop instead, use the _unchecked version of the function (for example xcb_intern_atom_unchecked). Here is an example which illustrates the four different ways of handling errors: /* * Request without a reply, handling errors in the event loop (default) * */ void my_example(xcb_connection *conn, xcb_window_t window) { /* This is a request without a reply. Errors will be delivered to the event * loop. Getting an error to xcb_map_window most likely is a bug in our * program, so we don't need to check for that in a blocking way. */ xcb_map_window(conn, window); /* ... of course your event loop would not be in the same function ... */ while ((event = xcb_wait_for_event(conn)) != NULL) { if (event->response_type == 0) { fprintf("Received X11 error %d ", error->error_code); free(event); continue; } /* ... handle a normal event ... */ } } /* * Request without a reply, handling errors directly * */ void my_example(xcb_connection *conn, xcb_window_t deco, xcb_window_t window) { /* A reparenting window manager wants to know whether a new window was * successfully reparented. If not (because the window got destroyed * already, for example), it does not make sense to map an empty window * decoration at all, so we need to know this right now. */ xcb_void_cookie_t cookie = xcb_reparent_window_checked(conn, window, deco, 0, 0); xcb_generic_error_t *error; if ((error = xcb_request_check(conn, cookie))) { fprintf(stderr, "Could not reparent the window "); free(error); return; } /* ... do window manager stuff here ... */ } /* * Request with a reply, handling errors directly (default) * */ void my_example(xcb_connection *conn, xcb_window_t window) { xcb_intern_atom_cookie_t cookie; xcb_intern_atom_reply_t *reply; xcb_generic_error_t *error; cookie = xcb_intern_atom(c, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME"); /* ... do other work here if possible ... */ if ((reply = xcb_intern_atom_reply(c, cookie, &error))) { printf("The _NET_WM_NAME atom has ID %u0, reply->atom); free(reply); } else { fprintf(stderr, "X11 Error %d ", error->error_code); free(error); } } /* * Request with a reply, handling errors in the event loop * */ void my_example(xcb_connection *conn, xcb_window_t window) { xcb_intern_atom_cookie_t cookie; xcb_intern_atom_reply_t *reply; cookie = xcb_intern_atom_unchecked(c, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME"); /* ... do other work here if possible ... */ if ((reply = xcb_intern_atom_reply(c, cookie, NULL))) { printf("The _NET_WM_NAME atom has ID %u0, reply->atom); free(reply); } /* ... of course your event loop would not be in the same function ... */ while ((event = xcb_wait_for_event(conn)) != NULL) { if (event->response_type == 0) { fprintf("Received X11 error %d ", error->error_code); free(event); continue; } /* ... handle a normal event ... */ } } SEE ALSO
xcb_map_window(3), xcb_intern_atom(3), xcb_list_fonts(3), xcb_poll_for_event(3), xcb_request_check(3) AUTHOR
Michael Stapelberg <michael+xcb at stapelberg dot de> XCB
2011-12-11 xcb-requests(3)
Man Page