XCB  1.13.1
xcb.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2001-2006 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 
32 #if defined(__solaris__)
33 #include <inttypes.h>
34 #else
35 #include <stdint.h>
36 #endif
37 
38 #ifndef _WIN32
39 #include <sys/uio.h>
40 #else
41 #include "xcb_windefs.h"
42 #endif
43 #include <pthread.h>
44 
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
54 #define XCB_PACKED __attribute__((__packed__))
55 
63 /* Pre-defined constants */
64 
66 #define X_PROTOCOL 11
67 
69 #define X_PROTOCOL_REVISION 0
70 
72 #define X_TCP_PORT 6000
73 
75 #define XCB_CONN_ERROR 1
76 
78 #define XCB_CONN_CLOSED_EXT_NOTSUPPORTED 2
79 
81 #define XCB_CONN_CLOSED_MEM_INSUFFICIENT 3
82 
84 #define XCB_CONN_CLOSED_REQ_LEN_EXCEED 4
85 
87 #define XCB_CONN_CLOSED_PARSE_ERR 5
88 
90 #define XCB_CONN_CLOSED_INVALID_SCREEN 6
91 
93 #define XCB_CONN_CLOSED_FDPASSING_FAILED 7
94 
95 #define XCB_TYPE_PAD(T,I) (-(I) & (sizeof(T) > 4 ? 3 : sizeof(T) - 1))
96 
97 /* Opaque structures */
98 
107 /* Other types */
108 
114 typedef struct {
115  void *data;
116  int rem;
117  int index;
119 
125 typedef struct {
126  uint8_t response_type;
127  uint8_t pad0;
128  uint16_t sequence;
129  uint32_t length;
131 
137 typedef struct {
138  uint8_t response_type;
139  uint8_t pad0;
140  uint16_t sequence;
141  uint32_t pad[7];
142  uint32_t full_sequence;
144 
150 typedef struct {
151  uint8_t response_type;
152  uint8_t pad0;
153  uint16_t sequence;
154  uint32_t pad[7];
156 
166 typedef struct {
167  uint8_t response_type;
168  uint8_t pad0;
169  uint16_t sequence;
170  uint32_t length;
171  uint16_t event_type;
172  uint16_t pad1;
173  uint32_t pad[5];
174  uint32_t full_sequence;
176 
182 typedef struct {
183  uint8_t response_type;
184  uint8_t error_code;
185  uint16_t sequence;
186  uint32_t resource_id;
187  uint16_t minor_code;
188  uint8_t major_code;
189  uint8_t pad0;
190  uint32_t pad[5];
191  uint32_t full_sequence;
193 
199 typedef struct {
200  unsigned int sequence;
202 
203 
204 /* Include the generated xproto header. */
205 #include "xproto.h"
206 
207 
209 #define XCB_NONE 0L
210 
212 #define XCB_COPY_FROM_PARENT 0L
213 
215 #define XCB_CURRENT_TIME 0L
216 
218 #define XCB_NO_SYMBOL 0L
219 
220 
221 /* xcb_auth.c */
222 
228 typedef struct xcb_auth_info_t {
229  int namelen;
230  char *name;
231  int datalen;
232  char *data;
234 
235 
236 /* xcb_out.c */
237 
247 
264 
283 
284 
285 /* xcb_in.c */
286 
297 
310 
326 
328 
333  xcb_special_event_t *se);
334 
339  xcb_special_event_t *se);
349  xcb_extension_t *ext,
350  uint32_t eid,
351  uint32_t *stamp);
352 
357  xcb_special_event_t *se);
358 
376 
391 void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence);
392 
412 void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence);
413 
414 /* xcb_ext.c */
415 
433 
446 
447 
448 /* xcb_conn.c */
449 
468 const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
469 
479 
499 
518 
527 
528 
529 /* xcb_util.c */
530 
548 int xcb_parse_display(const char *name, char **host, int *display, int *screen);
549 
567 xcb_connection_t *xcb_connect(const char *displayname, int *screenp);
568 
586 xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb_auth_info_t *auth, int *screen);
587 
588 
589 /* xcb_xid.c */
590 
599 uint32_t xcb_generate_id(xcb_connection_t *c);
600 
601 
606 #ifdef __cplusplus
607 }
608 #endif
609 
610 
611 #endif /* __XCB_H__ */
xcb_poll_for_event
xcb_generic_event_t * xcb_poll_for_event(xcb_connection_t *c)
Returns the next event or error from the server.
Definition: xcb_in.c:720
xcb_special_event
Definition: xcb_in.c:64
xcb_generic_reply_t
Generic reply.
Definition: xcb.h:125
xcb_poll_for_queued_event
xcb_generic_event_t * xcb_poll_for_queued_event(xcb_connection_t *c)
Returns the next event without reading from the connection.
Definition: xcb_in.c:725
xcb_get_setup
const struct xcb_setup_t * xcb_get_setup(xcb_connection_t *c)
Access the data returned by the server.
Definition: xcb_conn.c:309
xcb_generic_reply_t::pad0
uint8_t pad0
Definition: xcb.h:127
xcb_connect_to_display_with_auth_info
xcb_connection_t * xcb_connect_to_display_with_auth_info(const char *display, xcb_auth_info_t *auth, int *screen)
Connects to the X server, using an authorization information.
Definition: xcb_util.c:492
xcb_generic_error_t::major_code
uint8_t major_code
Definition: xcb.h:188
xcb_connect
xcb_connection_t * xcb_connect(const char *displayname, int *screenp)
Connects to the X server.
Definition: xcb_util.c:487
xcb_discard_reply
void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence)
Discards the reply for a request.
Definition: xcb_in.c:623
xcb_request_check
xcb_generic_error_t * xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie)
Return the error for a request, or NULL if none can ever arrive.
Definition: xcb_in.c:730
xcb_auth_info_t
struct xcb_auth_info_t xcb_auth_info_t
Container for authorization information.
xcb_discard_reply64
void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence)
Discards the reply for a request, given by a 64bit sequence number.
Definition: xcb_in.c:637
xcb_get_file_descriptor
int xcb_get_file_descriptor(xcb_connection_t *c)
Access the file descriptor of the connection.
Definition: xcb_conn.c:317
xcb_flush
int xcb_flush(xcb_connection_t *c)
Forces any buffered output to be written to the server.
Definition: xcb_out.c:417
xcb_parse_display
int xcb_parse_display(const char *name, char **host, int *display, int *screen)
Parses a display string name in the form documented by X(7x).
Definition: xcb_util.c:212
xcb_prefetch_maximum_request_length
void xcb_prefetch_maximum_request_length(xcb_connection_t *c)
Prefetch the maximum request length without blocking.
Definition: xcb_out.c:135
xcb_generic_reply_t::response_type
uint8_t response_type
Definition: xcb.h:126
xcb_generic_error_t::sequence
uint16_t sequence
Definition: xcb.h:185
xcb_generic_error_t::minor_code
uint16_t minor_code
Definition: xcb.h:187
xcb_generic_event_t
Generic event.
Definition: xcb.h:137
xcb_connect_to_fd
xcb_connection_t * xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info)
Connects to the X server.
Definition: xcb_conn.c:331
xcb_raw_generic_event_t::sequence
uint16_t sequence
Definition: xcb.h:153
xcb_auth_info_t
Container for authorization information.
Definition: xcb.h:228
xcb_connection_t
Definition: xcbint.h:195
xcb_ge_event_t::pad0
uint8_t pad0
Definition: xcb.h:168
xcb_generic_iterator_t::data
void * data
Definition: xcb.h:115
xcb_generic_reply_t::length
uint32_t length
Definition: xcb.h:129
xcb_raw_generic_event_t::response_type
uint8_t response_type
Definition: xcb.h:151
xcb_disconnect
void xcb_disconnect(xcb_connection_t *c)
Closes the connection.
Definition: xcb_conn.c:371
xcb_unregister_for_special_event
void xcb_unregister_for_special_event(xcb_connection_t *c, xcb_special_event_t *se)
Stop listening for a special event.
Definition: xcb_in.c:849
xcb_generic_event_t::response_type
uint8_t response_type
Definition: xcb.h:138
xcb_generic_error_t
Generic error.
Definition: xcb.h:182
xcb_raw_generic_event_t
Raw Generic event.
Definition: xcb.h:150
xcb_poll_for_special_event
xcb_generic_event_t * xcb_poll_for_special_event(xcb_connection_t *c, xcb_special_event_t *se)
Returns the next event from a special queue.
Definition: xcb_in.c:766
xcb_generic_reply_t::sequence
uint16_t sequence
Definition: xcb.h:128
xcb_ge_event_t
GE event.
Definition: xcb.h:166
xcb_generic_error_t::full_sequence
uint32_t full_sequence
Definition: xcb.h:191
xcb_auth_info_t::datalen
int datalen
Definition: xcb.h:231
xcb_generate_id
uint32_t xcb_generate_id(xcb_connection_t *c)
Allocates an XID for a new object.
Definition: xcb_xid.c:41
xcb_generic_event_t::sequence
uint16_t sequence
Definition: xcb.h:140
xcb_ge_event_t::sequence
uint16_t sequence
Definition: xcb.h:169
xcb_register_for_special_xge
xcb_special_event_t * xcb_register_for_special_xge(xcb_connection_t *c, xcb_extension_t *ext, uint32_t eid, uint32_t *stamp)
Listen for a special event.
Definition: xcb_in.c:806
xcb_auth_info_t::name
char * name
Definition: xcb.h:230
xcb_query_extension_reply_t
xcb_query_extension_reply_t
Definition: xproto.h:4287
xcb_extension_t
Definition: xcbext.h:39
xcb_generic_iterator_t::index
int index
Definition: xcb.h:117
xcb_generic_iterator_t::rem
int rem
Definition: xcb.h:116
xcb_generic_error_t::error_code
uint8_t error_code
Definition: xcb.h:184
xcb_generic_error_t::response_type
uint8_t response_type
Definition: xcb.h:183
xcb_wait_for_special_event
xcb_generic_event_t * xcb_wait_for_special_event(xcb_connection_t *c, xcb_special_event_t *se)
Returns the next event from a special queue, blocking until one arrives.
Definition: xcb_in.c:781
xcb_auth_info_t::namelen
int namelen
Definition: xcb.h:229
xcb_generic_iterator_t
Generic iterator.
Definition: xcb.h:114
xcb_auth_info_t::data
char * data
Definition: xcb.h:232
xcb_setup_t
xcb_setup_t
Definition: xproto.h:475
xcb_generic_error_t::pad0
uint8_t pad0
Definition: xcb.h:189
xcb_ge_event_t::response_type
uint8_t response_type
Definition: xcb.h:167
xcb_generic_event_t::full_sequence
uint32_t full_sequence
Definition: xcb.h:142
xcb_get_maximum_request_length
uint32_t xcb_get_maximum_request_length(xcb_connection_t *c)
Returns the maximum request length that this server accepts.
Definition: xcb_out.c:158
xcb_ge_event_t::full_sequence
uint32_t full_sequence
Definition: xcb.h:174
xcb_get_extension_data
const struct xcb_query_extension_reply_t * xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext)
Caches reply information from QueryExtension requests.
Definition: xcb_ext.c:88
xcb_raw_generic_event_t::pad0
uint8_t pad0
Definition: xcb.h:152
xcb_connection_has_error
int xcb_connection_has_error(xcb_connection_t *c)
Test whether the connection has shut down due to a fatal error.
Definition: xcb_conn.c:325
xcb_wait_for_event
xcb_generic_event_t * xcb_wait_for_event(xcb_connection_t *c)
Returns the next event or error from the server.
Definition: xcb_in.c:689
xcb_prefetch_extension_data
void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext)
Prefetch of extension data into the extension cache.
Definition: xcb_ext.c:106
xcb_generic_event_t::pad0
uint8_t pad0
Definition: xcb.h:139