2 * Copyright (C) 2008 Julien Danjou <julien@danjou.info>
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 * Except as contained in this notice, the names of the authors or
24 * their institutions shall not be used in advertising or otherwise to
25 * promote the sale, use or other dealings in this Software without
26 * prior written authorization from the authors.
30 * @defgroup xcb__reply_t XCB Reply Functions
32 * These functions ease the usage of asynchronous possibility of XCB about
33 * the reply retrieve of sent requests.
38 #ifndef __XCB_REPLY_H__
39 #define __XCB_REPLY_H__
48 typedef void (*xcb_generic_reply_handler_t)(void *data, xcb_connection_t *c, xcb_generic_reply_t *reply, xcb_generic_error_t *error);
52 struct xcb_reply_node *next;
54 xcb_generic_reply_handler_t handler;
59 struct xcb_reply_handlers
63 struct xcb_reply_node *head;
68 typedef struct xcb_reply_handlers xcb_reply_handlers_t;
71 * @brief Initialize a reply handlers structure.
72 * @param c The connection to the X server.
73 * @param h The reply handlers.
75 void xcb_reply_handlers_init(xcb_connection_t *c, xcb_reply_handlers_t *h);
78 * @brief Get the connection to the X server used in reply handlers.
79 * @param h The reply handlers data structure.
80 * @return The connection to the X server.
82 xcb_connection_t *xcb_reply_get_xcb_connection(xcb_reply_handlers_t *h);
85 * @brief Poll for reply using reply handlers.
86 * @param h The reply handlers data structure.
87 * @return The value return by the handler callback function, or 0 if no
90 int xcb_reply_poll_for_reply(xcb_reply_handlers_t *h);
93 * @brief Start reply handling thread.
94 * This thread will run forever until it is stop with xcb_reply_stop_thread.
95 * @param h The reply handlers.
97 void xcb_reply_start_thread(xcb_reply_handlers_t *h);
100 * @brief Stop reply handling thread.
101 * @param h The reply handlers.
103 void xcb_reply_stop_thread(xcb_reply_handlers_t *h);
106 * @brief Add a reply handler.
107 * @param h The reply handlers data structure to fill.
108 * @param request The request identifier.
109 * @param handler The handler to call for this request.
110 * @param data Optional data passed to the callback function handling request.
112 void xcb_reply_add_handler(xcb_reply_handlers_t *h, unsigned int request, xcb_generic_reply_handler_t handler, void *data);
122 #endif /* __XCB_REPLY_H__ */