annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/xcb/xcbext.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /*
jpayne@69 2 * Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
jpayne@69 3 * All Rights Reserved.
jpayne@69 4 *
jpayne@69 5 * Permission is hereby granted, free of charge, to any person obtaining a
jpayne@69 6 * copy of this software and associated documentation files (the "Software"),
jpayne@69 7 * to deal in the Software without restriction, including without limitation
jpayne@69 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
jpayne@69 9 * and/or sell copies of the Software, and to permit persons to whom the
jpayne@69 10 * Software is furnished to do so, subject to the following conditions:
jpayne@69 11 *
jpayne@69 12 * The above copyright notice and this permission notice shall be included in
jpayne@69 13 * all copies or substantial portions of the Software.
jpayne@69 14 *
jpayne@69 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jpayne@69 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jpayne@69 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jpayne@69 18 * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
jpayne@69 19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
jpayne@69 20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
jpayne@69 21 *
jpayne@69 22 * Except as contained in this notice, the names of the authors or their
jpayne@69 23 * institutions shall not be used in advertising or otherwise to promote the
jpayne@69 24 * sale, use or other dealings in this Software without prior written
jpayne@69 25 * authorization from the authors.
jpayne@69 26 */
jpayne@69 27
jpayne@69 28 #ifndef __XCBEXT_H
jpayne@69 29 #define __XCBEXT_H
jpayne@69 30
jpayne@69 31 #include "xcb.h"
jpayne@69 32
jpayne@69 33 #ifdef __cplusplus
jpayne@69 34 extern "C" {
jpayne@69 35 #endif
jpayne@69 36
jpayne@69 37 /* xcb_ext.c */
jpayne@69 38
jpayne@69 39 struct xcb_extension_t {
jpayne@69 40 const char *name;
jpayne@69 41 int global_id;
jpayne@69 42 };
jpayne@69 43
jpayne@69 44
jpayne@69 45 /* xcb_out.c */
jpayne@69 46
jpayne@69 47 typedef struct {
jpayne@69 48 size_t count;
jpayne@69 49 xcb_extension_t *ext;
jpayne@69 50 uint8_t opcode;
jpayne@69 51 uint8_t isvoid;
jpayne@69 52 } xcb_protocol_request_t;
jpayne@69 53
jpayne@69 54 enum xcb_send_request_flags_t {
jpayne@69 55 XCB_REQUEST_CHECKED = 1 << 0,
jpayne@69 56 XCB_REQUEST_RAW = 1 << 1,
jpayne@69 57 XCB_REQUEST_DISCARD_REPLY = 1 << 2,
jpayne@69 58 XCB_REQUEST_REPLY_FDS = 1 << 3
jpayne@69 59 };
jpayne@69 60
jpayne@69 61 /**
jpayne@69 62 * @brief Send a request to the server.
jpayne@69 63 * @param c The connection to the X server.
jpayne@69 64 * @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
jpayne@69 65 * @param vector Data to send; must have two iovecs before start for internal use.
jpayne@69 66 * @param request Information about the request to be sent.
jpayne@69 67 * @return The request's sequence number on success, 0 otherwise.
jpayne@69 68 *
jpayne@69 69 * This function sends a new request to the X server. The data of the request is
jpayne@69 70 * given as an array of @c iovecs in the @p vector argument. The length of that
jpayne@69 71 * array and the necessary management information are given in the @p request
jpayne@69 72 * argument.
jpayne@69 73 *
jpayne@69 74 * When this function returns, the request might or might not be sent already.
jpayne@69 75 * Use xcb_flush() to make sure that it really was sent.
jpayne@69 76 *
jpayne@69 77 * Please note that this function is not the preferred way for sending requests.
jpayne@69 78 * It's better to use the generated wrapper functions.
jpayne@69 79 *
jpayne@69 80 * Please note that xcb might use index -1 and -2 of the @p vector array internally,
jpayne@69 81 * so they must be valid!
jpayne@69 82 */
jpayne@69 83 unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
jpayne@69 84
jpayne@69 85 /**
jpayne@69 86 * @brief Send a request to the server.
jpayne@69 87 * @param c The connection to the X server.
jpayne@69 88 * @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
jpayne@69 89 * @param vector Data to send; must have two iovecs before start for internal use.
jpayne@69 90 * @param request Information about the request to be sent.
jpayne@69 91 * @param num_fds Number of additional file descriptors to send to the server
jpayne@69 92 * @param fds Additional file descriptors that should be send to the server.
jpayne@69 93 * @return The request's sequence number on success, 0 otherwise.
jpayne@69 94 *
jpayne@69 95 * This function sends a new request to the X server. The data of the request is
jpayne@69 96 * given as an array of @c iovecs in the @p vector argument. The length of that
jpayne@69 97 * array and the necessary management information are given in the @p request
jpayne@69 98 * argument.
jpayne@69 99 *
jpayne@69 100 * If @p num_fds is non-zero, @p fds points to an array of file descriptors that
jpayne@69 101 * will be sent to the X server along with this request. After this function
jpayne@69 102 * returns, all file descriptors sent are owned by xcb and will be closed
jpayne@69 103 * eventually.
jpayne@69 104 *
jpayne@69 105 * When this function returns, the request might or might not be sent already.
jpayne@69 106 * Use xcb_flush() to make sure that it really was sent.
jpayne@69 107 *
jpayne@69 108 * Please note that this function is not the preferred way for sending requests.
jpayne@69 109 *
jpayne@69 110 * Please note that xcb might use index -1 and -2 of the @p vector array internally,
jpayne@69 111 * so they must be valid!
jpayne@69 112 */
jpayne@69 113 unsigned int xcb_send_request_with_fds(xcb_connection_t *c, int flags, struct iovec *vector,
jpayne@69 114 const xcb_protocol_request_t *request, unsigned int num_fds, int *fds);
jpayne@69 115
jpayne@69 116 /**
jpayne@69 117 * @brief Send a request to the server, with 64-bit sequence number returned.
jpayne@69 118 * @param c The connection to the X server.
jpayne@69 119 * @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
jpayne@69 120 * @param vector Data to send; must have two iovecs before start for internal use.
jpayne@69 121 * @param request Information about the request to be sent.
jpayne@69 122 * @return The request's sequence number on success, 0 otherwise.
jpayne@69 123 *
jpayne@69 124 * This function sends a new request to the X server. The data of the request is
jpayne@69 125 * given as an array of @c iovecs in the @p vector argument. The length of that
jpayne@69 126 * array and the necessary management information are given in the @p request
jpayne@69 127 * argument.
jpayne@69 128 *
jpayne@69 129 * When this function returns, the request might or might not be sent already.
jpayne@69 130 * Use xcb_flush() to make sure that it really was sent.
jpayne@69 131 *
jpayne@69 132 * Please note that this function is not the preferred way for sending requests.
jpayne@69 133 * It's better to use the generated wrapper functions.
jpayne@69 134 *
jpayne@69 135 * Please note that xcb might use index -1 and -2 of the @p vector array internally,
jpayne@69 136 * so they must be valid!
jpayne@69 137 */
jpayne@69 138 uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
jpayne@69 139
jpayne@69 140 /**
jpayne@69 141 * @brief Send a request to the server, with 64-bit sequence number returned.
jpayne@69 142 * @param c The connection to the X server.
jpayne@69 143 * @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
jpayne@69 144 * @param vector Data to send; must have two iovecs before start for internal use.
jpayne@69 145 * @param request Information about the request to be sent.
jpayne@69 146 * @param num_fds Number of additional file descriptors to send to the server
jpayne@69 147 * @param fds Additional file descriptors that should be send to the server.
jpayne@69 148 * @return The request's sequence number on success, 0 otherwise.
jpayne@69 149 *
jpayne@69 150 * This function sends a new request to the X server. The data of the request is
jpayne@69 151 * given as an array of @c iovecs in the @p vector argument. The length of that
jpayne@69 152 * array and the necessary management information are given in the @p request
jpayne@69 153 * argument.
jpayne@69 154 *
jpayne@69 155 * If @p num_fds is non-zero, @p fds points to an array of file descriptors that
jpayne@69 156 * will be sent to the X server along with this request. After this function
jpayne@69 157 * returns, all file descriptors sent are owned by xcb and will be closed
jpayne@69 158 * eventually.
jpayne@69 159 *
jpayne@69 160 * When this function returns, the request might or might not be sent already.
jpayne@69 161 * Use xcb_flush() to make sure that it really was sent.
jpayne@69 162 *
jpayne@69 163 * Please note that this function is not the preferred way for sending requests.
jpayne@69 164 * It's better to use the generated wrapper functions.
jpayne@69 165 *
jpayne@69 166 * Please note that xcb might use index -1 and -2 of the @p vector array internally,
jpayne@69 167 * so they must be valid!
jpayne@69 168 */
jpayne@69 169 uint64_t xcb_send_request_with_fds64(xcb_connection_t *c, int flags, struct iovec *vector,
jpayne@69 170 const xcb_protocol_request_t *request, unsigned int num_fds, int *fds);
jpayne@69 171
jpayne@69 172 /**
jpayne@69 173 * @brief Send a file descriptor to the server in the next call to xcb_send_request.
jpayne@69 174 * @param c The connection to the X server.
jpayne@69 175 * @param fd The file descriptor to send.
jpayne@69 176 *
jpayne@69 177 * After this function returns, the file descriptor given is owned by xcb and
jpayne@69 178 * will be closed eventually.
jpayne@69 179 *
jpayne@69 180 * @deprecated This function cannot be used in a thread-safe way. Two threads
jpayne@69 181 * that run xcb_send_fd(); xcb_send_request(); could mix up their file
jpayne@69 182 * descriptors. Instead, xcb_send_request_with_fds() should be used.
jpayne@69 183 */
jpayne@69 184 void xcb_send_fd(xcb_connection_t *c, int fd);
jpayne@69 185
jpayne@69 186 /**
jpayne@69 187 * @brief Take over the write side of the socket
jpayne@69 188 * @param c The connection to the X server.
jpayne@69 189 * @param return_socket Callback function that will be called when xcb wants
jpayne@69 190 * to use the socket again.
jpayne@69 191 * @param closure Argument to the callback function.
jpayne@69 192 * @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
jpayne@69 193 * @param sent Location to the sequence number of the last sequence request.
jpayne@69 194 * Must not be NULL.
jpayne@69 195 * @return 1 on success, else 0.
jpayne@69 196 *
jpayne@69 197 * xcb_take_socket allows external code to ask XCB for permission to
jpayne@69 198 * take over the write side of the socket and send raw data with
jpayne@69 199 * xcb_writev. xcb_take_socket provides the sequence number of the last
jpayne@69 200 * request XCB sent. The caller of xcb_take_socket must supply a
jpayne@69 201 * callback which XCB can call when it wants the write side of the
jpayne@69 202 * socket back to make a request. This callback synchronizes with the
jpayne@69 203 * external socket owner and flushes any output queues if appropriate.
jpayne@69 204 * If you are sending requests which won't cause a reply, please note the
jpayne@69 205 * comment for xcb_writev which explains some sequence number wrap issues.
jpayne@69 206 *
jpayne@69 207 * All replies that are generated while the socket is owned externally have
jpayne@69 208 * @p flags applied to them. For example, use XCB_REQUEST_CHECK if you don't
jpayne@69 209 * want errors to go to xcb's normal error handling, but instead having to be
jpayne@69 210 * picked up via xcb_wait_for_reply(), xcb_poll_for_reply() or
jpayne@69 211 * xcb_request_check().
jpayne@69 212 */
jpayne@69 213 int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent);
jpayne@69 214
jpayne@69 215 /**
jpayne@69 216 * @brief Send raw data to the X server.
jpayne@69 217 * @param c The connection to the X server.
jpayne@69 218 * @param vector Array of data to be sent.
jpayne@69 219 * @param count Number of entries in @p vector.
jpayne@69 220 * @param requests Number of requests that are being sent.
jpayne@69 221 * @return 1 on success, else 0.
jpayne@69 222 *
jpayne@69 223 * You must own the write-side of the socket (you've called
jpayne@69 224 * xcb_take_socket, and haven't returned from return_socket yet) to call
jpayne@69 225 * xcb_writev. Also, the iovec must have at least 1 byte of data in it.
jpayne@69 226 * You have to make sure that xcb can detect sequence number wraps correctly.
jpayne@69 227 * This means that the first request you send after xcb_take_socket must cause a
jpayne@69 228 * reply (e.g. just insert a GetInputFocus request). After every (1 << 16) - 1
jpayne@69 229 * requests without a reply, you have to insert a request which will cause a
jpayne@69 230 * reply. You can again use GetInputFocus for this. You do not have to wait for
jpayne@69 231 * any of the GetInputFocus replies, but can instead handle them via
jpayne@69 232 * xcb_discard_reply().
jpayne@69 233 */
jpayne@69 234 int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t requests);
jpayne@69 235
jpayne@69 236
jpayne@69 237 /* xcb_in.c */
jpayne@69 238
jpayne@69 239 /**
jpayne@69 240 * @brief Wait for the reply of a given request.
jpayne@69 241 * @param c The connection to the X server.
jpayne@69 242 * @param request Sequence number of the request as returned by xcb_send_request().
jpayne@69 243 * @param e Location to store errors in, or NULL. Ignored for unchecked requests.
jpayne@69 244 *
jpayne@69 245 * Returns the reply to the given request or returns null in the event of
jpayne@69 246 * errors. Blocks until the reply or error for the request arrives, or an I/O
jpayne@69 247 * error occurs.
jpayne@69 248 */
jpayne@69 249 void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
jpayne@69 250
jpayne@69 251 /**
jpayne@69 252 * @brief Wait for the reply of a given request, with 64-bit sequence number
jpayne@69 253 * @param c The connection to the X server.
jpayne@69 254 * @param request 64-bit sequence number of the request as returned by xcb_send_request64().
jpayne@69 255 * @param e Location to store errors in, or NULL. Ignored for unchecked requests.
jpayne@69 256 *
jpayne@69 257 * Returns the reply to the given request or returns null in the event of
jpayne@69 258 * errors. Blocks until the reply or error for the request arrives, or an I/O
jpayne@69 259 * error occurs.
jpayne@69 260 *
jpayne@69 261 * Unlike its xcb_wait_for_reply() counterpart, the given sequence number is not
jpayne@69 262 * automatically "widened" to 64-bit.
jpayne@69 263 */
jpayne@69 264 void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e);
jpayne@69 265
jpayne@69 266 /**
jpayne@69 267 * @brief Poll for the reply of a given request.
jpayne@69 268 * @param c The connection to the X server.
jpayne@69 269 * @param request Sequence number of the request as returned by xcb_send_request().
jpayne@69 270 * @param reply Location to store the reply in, must not be NULL.
jpayne@69 271 * @param error Location to store errors in, or NULL. Ignored for unchecked requests.
jpayne@69 272 * @return 1 when the reply to the request was returned, else 0.
jpayne@69 273 *
jpayne@69 274 * Checks if the reply to the given request already received. Does not block.
jpayne@69 275 */
jpayne@69 276 int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
jpayne@69 277
jpayne@69 278 /**
jpayne@69 279 * @brief Poll for the reply of a given request, with 64-bit sequence number.
jpayne@69 280 * @param c The connection to the X server.
jpayne@69 281 * @param request 64-bit sequence number of the request as returned by xcb_send_request().
jpayne@69 282 * @param reply Location to store the reply in, must not be NULL.
jpayne@69 283 * @param error Location to store errors in, or NULL. Ignored for unchecked requests.
jpayne@69 284 * @return 1 when the reply to the request was returned, else 0.
jpayne@69 285 *
jpayne@69 286 * Checks if the reply to the given request already received. Does not block.
jpayne@69 287 *
jpayne@69 288 * Unlike its xcb_poll_for_reply() counterpart, the given sequence number is not
jpayne@69 289 * automatically "widened" to 64-bit.
jpayne@69 290 */
jpayne@69 291 int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error);
jpayne@69 292
jpayne@69 293 /**
jpayne@69 294 * @brief Don't use this, only needed by the generated code.
jpayne@69 295 * @param c The connection to the X server.
jpayne@69 296 * @param reply A reply that was received from the server
jpayne@69 297 * @param replylen The size of the reply.
jpayne@69 298 * @return Pointer to the location where received file descriptors are stored.
jpayne@69 299 */
jpayne@69 300 int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t replylen);
jpayne@69 301
jpayne@69 302
jpayne@69 303 /* xcb_util.c */
jpayne@69 304
jpayne@69 305 /**
jpayne@69 306 * @param mask The mask to check
jpayne@69 307 * @return The number of set bits in the mask
jpayne@69 308 */
jpayne@69 309 int xcb_popcount(uint32_t mask);
jpayne@69 310
jpayne@69 311 /**
jpayne@69 312 * @param list The base of an array
jpayne@69 313 * @param len The length of the array
jpayne@69 314 * @return The sum of all entries in the array.
jpayne@69 315 */
jpayne@69 316 int xcb_sumof(uint8_t *list, int len);
jpayne@69 317
jpayne@69 318 #ifdef __cplusplus
jpayne@69 319 }
jpayne@69 320 #endif
jpayne@69 321
jpayne@69 322 #endif