2 * vim:ts=4:sw=4:expandtab
10 #include <xcb/xproto.h>
13 * Try to get the socket path from X11 and return NULL if it doesn’t work.
15 * The memory for the socket path is dynamically allocated and has to be
16 * free()d by the caller.
19 char *socket_path_from_x11();
22 * Safe-wrapper around malloc which exits if malloc returns NULL (meaning that
23 * there is no more memory available)
26 void *smalloc(size_t size);
29 * Safe-wrapper around calloc which exits if malloc returns NULL (meaning that
30 * there is no more memory available)
33 void *scalloc(size_t size);
36 * Safe-wrapper around realloc which exits if realloc returns NULL (meaning
37 * that there is no more memory available).
40 void *srealloc(void *ptr, size_t size);
43 * Safe-wrapper around strdup which exits if malloc returns NULL (meaning that
44 * there is no more memory available)
47 char *sstrdup(const char *str);
50 * Safe-wrapper around asprintf which exits if it returns -1 (meaning that
51 * there is no more memory available)
54 int sasprintf(char **strp, const char *fmt, ...);
57 * Formats a message (payload) of the given size and type and sends it to i3 via
58 * the given socket file descriptor.
60 * Returns -1 when write() fails, errno will remain.
61 * Returns 0 on success.
64 int ipc_send_message(int sockfd, uint32_t message_size,
65 uint32_t message_type, const uint8_t *payload);
68 * Reads a message from the given socket file descriptor and stores its length
69 * (reply_length) as well as a pointer to its contents (reply).
71 * Returns -1 when read() fails, errno will remain.
72 * Returns -2 when the IPC protocol is violated (invalid magic, unexpected
73 * message type, EOF instead of a message). Additionally, the error will be
75 * Returns 0 on success.
78 int ipc_recv_message(int sockfd, uint32_t message_type,
79 uint32_t *reply_length, uint8_t **reply);
82 * Generates a configure_notify event and sends it to the given window
83 * Applications need this to think they’ve configured themselves correctly.
84 * The truth is, however, that we will manage them.
87 void fake_configure_notify(xcb_connection_t *conn, xcb_rectangle_t r, xcb_window_t window, int border_width);