xcb\_intern\_atom(3) XCB Requests xcb\_intern\_atom(3)

# [NAME](#NAME)

xcb\_intern\_atom - Get atom identifier by name

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;xcb/xproto.h&gt;**

## [Request function](#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](#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](#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](#REQUEST_ARGUMENTS)

[*conn*](#conn)

The XCB connection to X11.

[*only\_if\_exists*](#only_if_exists)

Return a valid atom id only if the atom already exists.

[*name\_len*](#name_len)

The length of the following *name*.

[*name*](#name)

The name of the atom.

# [REPLY FIELDS](#REPLY_FIELDS)

[*response\_type*](#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*](#sequence)

The sequence number of the last request processed by the X11 server.

[*length*](#length)

The length of the reply, in words (a word is 4 bytes).

[*atom*](#atom)

TODO: NOT YET DOCUMENTED.

# [DESCRIPTION](#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](#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)**](/man/os/libxcb/xcb-requests.3) for details.

# [ERRORS](#ERRORS)

[*xcb\_alloc\_error\_t*](#xcb_alloc_error_t)

TODO: reasons?

[*xcb\_value\_error\_t*](#xcb_value_error_t)

A value other than 0 or 1 was specified for *only\_if\_exists*.

# [EXAMPLE](#EXAMPLE)

```
/*


 * Resolves the _NET_WM_NAME atom.


 *


 */
void my_example(xcb_connection_t *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](#SEE_ALSO)

[**xcb-requests**(3)](/man/os/libxcb/xcb-requests.3), [**xcb-examples**(3)](/man/os/libxcb/xcb-examples.3), [**xcb\_get\_atom\_name**(3)](/man/os/libxcb/xcb_get_atom_name.3), [**xlsatoms**(1)](/man/os/libxcb/xlsatoms.1)

# [AUTHOR](#AUTHOR)

Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements.

libxcb 1.17.0 X Version 11

---

Document: xcb_intern_atom(3) from libxcb 1.17.0-r16 (Chainguard OS)
Source: https://gitlab.freedesktop.org/xorg/lib/libxcb.git
