Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:42

0001 /*
0002  * Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
0003  * All Rights Reserved.
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining a
0006  * copy of this software and associated documentation files (the "Software"),
0007  * to deal in the Software without restriction, including without limitation
0008  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0009  * and/or sell copies of the Software, and to permit persons to whom the
0010  * Software is furnished to do so, subject to the following conditions:
0011  * 
0012  * The above copyright notice and this permission notice shall be included in
0013  * all copies or substantial portions of the Software.
0014  * 
0015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0018  * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0019  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0020  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0021  * 
0022  * Except as contained in this notice, the names of the authors or their
0023  * institutions shall not be used in advertising or otherwise to promote the
0024  * sale, use or other dealings in this Software without prior written
0025  * authorization from the authors.
0026  */
0027 
0028 #ifndef __XCBEXT_H
0029 #define __XCBEXT_H
0030 
0031 #include "xcb.h"
0032 
0033 #ifdef __cplusplus
0034 extern "C" {
0035 #endif
0036 
0037 /* xcb_ext.c */
0038 
0039 struct xcb_extension_t {
0040     const char *name;
0041     int global_id;
0042 };
0043 
0044 
0045 /* xcb_out.c */
0046 
0047 typedef struct {
0048     size_t count;
0049     xcb_extension_t *ext;
0050     uint8_t opcode;
0051     uint8_t isvoid;
0052 } xcb_protocol_request_t;
0053 
0054 enum xcb_send_request_flags_t {
0055     XCB_REQUEST_CHECKED = 1 << 0,
0056     XCB_REQUEST_RAW = 1 << 1,
0057     XCB_REQUEST_DISCARD_REPLY = 1 << 2,
0058     XCB_REQUEST_REPLY_FDS = 1 << 3
0059 };
0060 
0061 /**
0062  * @brief Send a request to the server.
0063  * @param c The connection to the X server.
0064  * @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
0065  * @param vector Data to send; must have two iovecs before start for internal use.
0066  * @param request Information about the request to be sent.
0067  * @return The request's sequence number on success, 0 otherwise.
0068  *
0069  * This function sends a new request to the X server. The data of the request is
0070  * given as an array of @c iovecs in the @p vector argument. The length of that
0071  * array and the necessary management information are given in the @p request
0072  * argument.
0073  *
0074  * When this function returns, the request might or might not be sent already.
0075  * Use xcb_flush() to make sure that it really was sent.
0076  *
0077  * Please note that this function is not the preferred way for sending requests.
0078  * It's better to use the generated wrapper functions.
0079  *
0080  * Please note that xcb might use index -1 and -2 of the @p vector array internally,
0081  * so they must be valid!
0082  */
0083 unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
0084 
0085 /**
0086  * @brief Send a request to the server.
0087  * @param c The connection to the X server.
0088  * @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
0089  * @param vector Data to send; must have two iovecs before start for internal use.
0090  * @param request Information about the request to be sent.
0091  * @param num_fds Number of additional file descriptors to send to the server
0092  * @param fds Additional file descriptors that should be send to the server.
0093  * @return The request's sequence number on success, 0 otherwise.
0094  *
0095  * This function sends a new request to the X server. The data of the request is
0096  * given as an array of @c iovecs in the @p vector argument. The length of that
0097  * array and the necessary management information are given in the @p request
0098  * argument.
0099  *
0100  * If @p num_fds is non-zero, @p fds points to an array of file descriptors that
0101  * will be sent to the X server along with this request. After this function
0102  * returns, all file descriptors sent are owned by xcb and will be closed
0103  * eventually.
0104  *
0105  * When this function returns, the request might or might not be sent already.
0106  * Use xcb_flush() to make sure that it really was sent.
0107  *
0108  * Please note that this function is not the preferred way for sending requests.
0109  *
0110  * Please note that xcb might use index -1 and -2 of the @p vector array internally,
0111  * so they must be valid!
0112  */
0113 unsigned int xcb_send_request_with_fds(xcb_connection_t *c, int flags, struct iovec *vector,
0114                 const xcb_protocol_request_t *request, unsigned int num_fds, int *fds);
0115 
0116 /**
0117  * @brief Send a request to the server, with 64-bit sequence number returned.
0118  * @param c The connection to the X server.
0119  * @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
0120  * @param vector Data to send; must have two iovecs before start for internal use.
0121  * @param request Information about the request to be sent.
0122  * @return The request's sequence number on success, 0 otherwise.
0123  *
0124  * This function sends a new request to the X server. The data of the request is
0125  * given as an array of @c iovecs in the @p vector argument. The length of that
0126  * array and the necessary management information are given in the @p request
0127  * argument.
0128  *
0129  * When this function returns, the request might or might not be sent already.
0130  * Use xcb_flush() to make sure that it really was sent.
0131  *
0132  * Please note that this function is not the preferred way for sending requests.
0133  * It's better to use the generated wrapper functions.
0134  *
0135  * Please note that xcb might use index -1 and -2 of the @p vector array internally,
0136  * so they must be valid!
0137  */
0138 uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
0139 
0140 /**
0141  * @brief Send a request to the server, with 64-bit sequence number returned.
0142  * @param c The connection to the X server.
0143  * @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
0144  * @param vector Data to send; must have two iovecs before start for internal use.
0145  * @param request Information about the request to be sent.
0146  * @param num_fds Number of additional file descriptors to send to the server
0147  * @param fds Additional file descriptors that should be send to the server.
0148  * @return The request's sequence number on success, 0 otherwise.
0149  *
0150  * This function sends a new request to the X server. The data of the request is
0151  * given as an array of @c iovecs in the @p vector argument. The length of that
0152  * array and the necessary management information are given in the @p request
0153  * argument.
0154  *
0155  * If @p num_fds is non-zero, @p fds points to an array of file descriptors that
0156  * will be sent to the X server along with this request. After this function
0157  * returns, all file descriptors sent are owned by xcb and will be closed
0158  * eventually.
0159  *
0160  * When this function returns, the request might or might not be sent already.
0161  * Use xcb_flush() to make sure that it really was sent.
0162  *
0163  * Please note that this function is not the preferred way for sending requests.
0164  * It's better to use the generated wrapper functions.
0165  *
0166  * Please note that xcb might use index -1 and -2 of the @p vector array internally,
0167  * so they must be valid!
0168  */
0169 uint64_t xcb_send_request_with_fds64(xcb_connection_t *c, int flags, struct iovec *vector,
0170                 const xcb_protocol_request_t *request, unsigned int num_fds, int *fds);
0171 
0172 /**
0173  * @brief Send a file descriptor to the server in the next call to xcb_send_request.
0174  * @param c The connection to the X server.
0175  * @param fd The file descriptor to send.
0176  *
0177  * After this function returns, the file descriptor given is owned by xcb and
0178  * will be closed eventually.
0179  *
0180  * @deprecated This function cannot be used in a thread-safe way. Two threads
0181  * that run xcb_send_fd(); xcb_send_request(); could mix up their file
0182  * descriptors. Instead, xcb_send_request_with_fds() should be used.
0183  */
0184 void xcb_send_fd(xcb_connection_t *c, int fd);
0185 
0186 /**
0187  * @brief Take over the write side of the socket
0188  * @param c The connection to the X server.
0189  * @param return_socket Callback function that will be called when xcb wants
0190  *                        to use the socket again.
0191  * @param closure Argument to the callback function.
0192  * @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
0193  * @param sent Location to the sequence number of the last sequence request.
0194  *              Must not be NULL.
0195  * @return 1 on success, else 0.
0196  *
0197  * xcb_take_socket allows external code to ask XCB for permission to
0198  * take over the write side of the socket and send raw data with
0199  * xcb_writev. xcb_take_socket provides the sequence number of the last
0200  * request XCB sent. The caller of xcb_take_socket must supply a
0201  * callback which XCB can call when it wants the write side of the
0202  * socket back to make a request. This callback synchronizes with the
0203  * external socket owner and flushes any output queues if appropriate.
0204  * If you are sending requests which won't cause a reply, please note the
0205  * comment for xcb_writev which explains some sequence number wrap issues.
0206  *
0207  * All replies that are generated while the socket is owned externally have
0208  * @p flags applied to them. For example, use XCB_REQUEST_CHECK if you don't
0209  * want errors to go to xcb's normal error handling, but instead having to be
0210  * picked up via xcb_wait_for_reply(), xcb_poll_for_reply() or
0211  * xcb_request_check().
0212  */
0213 int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent);
0214 
0215 /**
0216  * @brief Send raw data to the X server.
0217  * @param c The connection to the X server.
0218  * @param vector Array of data to be sent.
0219  * @param count Number of entries in @p vector.
0220  * @param requests Number of requests that are being sent.
0221  * @return 1 on success, else 0.
0222  *
0223  * You must own the write-side of the socket (you've called
0224  * xcb_take_socket, and haven't returned from return_socket yet) to call
0225  * xcb_writev. Also, the iovec must have at least 1 byte of data in it.
0226  * You have to make sure that xcb can detect sequence number wraps correctly.
0227  * This means that the first request you send after xcb_take_socket must cause a
0228  * reply (e.g. just insert a GetInputFocus request). After every (1 << 16) - 1
0229  * requests without a reply, you have to insert a request which will cause a
0230  * reply. You can again use GetInputFocus for this. You do not have to wait for
0231  * any of the GetInputFocus replies, but can instead handle them via
0232  * xcb_discard_reply().
0233  */
0234 int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t requests);
0235 
0236 
0237 /* xcb_in.c */
0238 
0239 /**
0240  * @brief Wait for the reply of a given request.
0241  * @param c The connection to the X server.
0242  * @param request Sequence number of the request as returned by xcb_send_request().
0243  * @param e Location to store errors in, or NULL. Ignored for unchecked requests.
0244  *
0245  * Returns the reply to the given request or returns null in the event of
0246  * errors. Blocks until the reply or error for the request arrives, or an I/O
0247  * error occurs.
0248  */
0249 void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
0250 
0251 /**
0252  * @brief Wait for the reply of a given request, with 64-bit sequence number
0253  * @param c The connection to the X server.
0254  * @param request 64-bit sequence number of the request as returned by xcb_send_request64().
0255  * @param e Location to store errors in, or NULL. Ignored for unchecked requests.
0256  *
0257  * Returns the reply to the given request or returns null in the event of
0258  * errors. Blocks until the reply or error for the request arrives, or an I/O
0259  * error occurs.
0260  *
0261  * Unlike its xcb_wait_for_reply() counterpart, the given sequence number is not
0262  * automatically "widened" to 64-bit.
0263  */
0264 void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e);
0265 
0266 /**
0267  * @brief Poll for the reply of a given request.
0268  * @param c The connection to the X server.
0269  * @param request Sequence number of the request as returned by xcb_send_request().
0270  * @param reply Location to store the reply in, must not be NULL.
0271  * @param error Location to store errors in, or NULL. Ignored for unchecked requests.
0272  * @return 1 when the reply to the request was returned, else 0.
0273  *
0274  * Checks if the reply to the given request already received. Does not block.
0275  */
0276 int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
0277 
0278 /**
0279  * @brief Poll for the reply of a given request, with 64-bit sequence number.
0280  * @param c The connection to the X server.
0281  * @param request 64-bit sequence number of the request as returned by xcb_send_request().
0282  * @param reply Location to store the reply in, must not be NULL.
0283  * @param error Location to store errors in, or NULL. Ignored for unchecked requests.
0284  * @return 1 when the reply to the request was returned, else 0.
0285  *
0286  * Checks if the reply to the given request already received. Does not block.
0287  *
0288  * Unlike its xcb_poll_for_reply() counterpart, the given sequence number is not
0289  * automatically "widened" to 64-bit.
0290  */
0291 int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error);
0292 
0293 /**
0294  * @brief Don't use this, only needed by the generated code.
0295  * @param c The connection to the X server.
0296  * @param reply A reply that was received from the server
0297  * @param replylen The size of the reply.
0298  * @return Pointer to the location where received file descriptors are stored.
0299  */
0300 int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t replylen);
0301 
0302 
0303 /* xcb_util.c */
0304 
0305 /**
0306  * @param mask The mask to check
0307  * @return The number of set bits in the mask
0308  */
0309 int xcb_popcount(uint32_t mask);
0310 
0311 /**
0312  * @param list The base of an array
0313  * @param len The length of the array
0314  * @return The sum of all entries in the array.
0315  */
0316 int xcb_sumof(uint8_t *list, int len);
0317 
0318 #ifdef __cplusplus
0319 }
0320 #endif
0321 
0322 #endif