XCB 1.9
xcbext.h
00001 /*
00002  * Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
00003  * All Rights Reserved.
00004  *
00005  * Permission is hereby granted, free of charge, to any person obtaining a
00006  * copy of this software and associated documentation files (the "Software"),
00007  * to deal in the Software without restriction, including without limitation
00008  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00009  * and/or sell copies of the Software, and to permit persons to whom the
00010  * Software is furnished to do so, subject to the following conditions:
00011  * 
00012  * The above copyright notice and this permission notice shall be included in
00013  * all copies or substantial portions of the Software.
00014  * 
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018  * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00019  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00020  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021  * 
00022  * Except as contained in this notice, the names of the authors or their
00023  * institutions shall not be used in advertising or otherwise to promote the
00024  * sale, use or other dealings in this Software without prior written
00025  * authorization from the authors.
00026  */
00027 
00028 #ifndef __XCBEXT_H
00029 #define __XCBEXT_H
00030 
00031 #include "xcb.h"
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 /* xcb_ext.c */
00038 
00039 struct xcb_extension_t {
00040     const char *name;
00041     int global_id;
00042 };
00043 
00044 
00045 /* xcb_out.c */
00046 
00047 typedef struct {
00048     size_t count;
00049     xcb_extension_t *ext;
00050     uint8_t opcode;
00051     uint8_t isvoid;
00052 } xcb_protocol_request_t;
00053 
00054 enum xcb_send_request_flags_t {
00055     XCB_REQUEST_CHECKED = 1 << 0,
00056     XCB_REQUEST_RAW = 1 << 1,
00057     XCB_REQUEST_DISCARD_REPLY = 1 << 2
00058 };
00059 
00060 unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
00061 
00062 /* xcb_take_socket allows external code to ask XCB for permission to
00063  * take over the write side of the socket and send raw data with
00064  * xcb_writev. xcb_take_socket provides the sequence number of the last
00065  * request XCB sent. The caller of xcb_take_socket must supply a
00066  * callback which XCB can call when it wants the write side of the
00067  * socket back to make a request. This callback synchronizes with the
00068  * external socket owner and flushes any output queues if appropriate.
00069  * If you are sending requests which won't cause a reply, please note the
00070  * comment for xcb_writev which explains some sequence number wrap issues.
00071  * */
00072 int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent);
00073 
00074 /* You must own the write-side of the socket (you've called
00075  * xcb_take_socket, and haven't returned from return_socket yet) to call
00076  * xcb_writev. Also, the iovec must have at least 1 byte of data in it.
00077  * You have to make sure that xcb can detect sequence number wraps correctly.
00078  * This means that the first request you send after xcb_take_socket must cause a
00079  * reply (e.g. just insert a GetInputFocus request). After every (1 << 16) - 1
00080  * requests without a reply, you have to insert a request which will cause a
00081  * reply. You can again use GetInputFocus for this. You do not have to wait for
00082  * any of the GetInputFocus replies, but can instead handle them via
00083  * xcb_discard_reply(). */
00084 int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t requests);
00085 
00086 
00087 /* xcb_in.c */
00088 
00089 void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
00090 int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
00091 
00092 
00093 /* xcb_util.c */
00094 
00095 int xcb_popcount(uint32_t mask);
00096 int xcb_sumof(uint8_t *list, int len);
00097 
00098 #ifdef __cplusplus
00099 }
00100 #endif
00101 
00102 #endif