Merge branch 'master' of git+ssh://iano@git.freedesktop.org/git/xcb
[free-sw/xcb/libxcb] / src / xcb.h
1 /*
2  * Copyright (C) 2001-2004 Bart Massey, Jamey Sharp, and Josh Triplett.
3  * All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  * 
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  * 
22  * Except as contained in this notice, the names of the authors or their
23  * institutions shall not be used in advertising or otherwise to promote the
24  * sale, use or other dealings in this Software without prior written
25  * authorization from the authors.
26  */
27
28 #ifndef __XCB_H
29 #define __XCB_H
30 #include <sys/types.h>
31 #include <X11/Xmd.h>
32 #include <X11/X.h>
33 #include <sys/uio.h>
34 #include <pthread.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
41 #define deprecated __attribute__((__deprecated__))
42 #else
43 #define deprecated
44 #endif
45
46 /* Pre-defined constants */
47
48 /* current protocol version */
49 #define X_PROTOCOL 11
50
51 /* current minor version */
52 #define X_PROTOCOL_REVISION 0
53
54 /* X_TCP_PORT + display number = server port for TCP transport */
55 #define X_TCP_PORT 6000
56
57 #define XCB_TYPE_PAD(T,I) (-(I) & (sizeof(T) > 4 ? 3 : sizeof(T) - 1))
58
59
60 /* Opaque structures */
61
62 typedef struct XCBConnection XCBConnection;
63
64
65 /* Other types */
66
67 typedef struct {
68     void *data;
69     int rem;
70     int index;
71 } XCBGenericIter;
72
73 typedef struct {
74     BYTE response_type;
75     CARD8 pad0;
76     CARD16 sequence;
77     CARD32 length;
78 } XCBGenericRep;
79
80 typedef struct {
81     BYTE response_type;
82     CARD8 pad0;
83     CARD16 sequence;
84     CARD32 pad[7];
85     CARD32 full_sequence;
86 } XCBGenericEvent;
87
88 typedef struct {
89     BYTE response_type;
90     BYTE error_code;
91     CARD16 sequence;
92     CARD32 pad[7];
93     CARD32 full_sequence;
94 } XCBGenericError;
95
96 typedef struct {
97     unsigned int sequence;
98 } XCBVoidCookie;
99
100
101 /* Include the generated xproto and xcb_types headers. */
102 #include "xcb_types.h"
103 #include "xproto.h"
104
105
106 /* xcb_auth.c */
107
108 typedef struct XCBAuthInfo {
109     int namelen;
110     char *name;
111     int datalen;
112     char *data;
113 } XCBAuthInfo;
114
115 int XCBGetAuthInfo(int fd, XCBAuthInfo *info) deprecated;
116
117
118 /* xcb_out.c */
119
120 int XCBFlush(XCBConnection *c);
121 CARD32 XCBGetMaximumRequestLength(XCBConnection *c);
122
123
124 /* xcb_in.c */
125
126 XCBGenericEvent *XCBWaitEvent(XCBConnection *c) deprecated;
127 XCBGenericEvent *XCBWaitForEvent(XCBConnection *c);
128 XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error);
129 unsigned int XCBGetRequestRead(XCBConnection *c);
130
131
132 /* xcb_ext.c */
133
134 typedef struct XCBExtension XCBExtension;
135
136 /* Do not free the returned XCBQueryExtensionRep - on return, it's aliased
137  * from the cache. */
138 const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension *ext);
139
140 void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext);
141
142
143 /* xcb_conn.c */
144
145 XCBConnSetupSuccessRep *XCBGetSetup(XCBConnection *c);
146 int XCBGetFileDescriptor(XCBConnection *c);
147
148 XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info);
149 void XCBDisconnect(XCBConnection *c);
150
151
152 /* xcb_util.c */
153
154 int XCBParseDisplay(const char *name, char **host, int *display, int *screen);
155 int XCBOpen(const char *host, int display) deprecated;
156 int XCBOpenTCP(const char *host, unsigned short port) deprecated;
157 int XCBOpenUnix(const char *file) deprecated;
158
159 XCBConnection *XCBConnectBasic(void) deprecated;
160 XCBConnection *XCBConnect(const char *displayname, int *screenp);
161 XCBConnection *XCBConnectToDisplayWithAuthInfo(const char *display, XCBAuthInfo *auth, int *screen);
162
163 int XCBSync(XCBConnection *c, XCBGenericError **e);
164
165
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #endif