XCB: xcb.h Source File

XCB 1.17.0

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
47extern "C" {
48#endif
49
53
54#ifdef __GNUC__
55#define XCB_PACKED __attribute__((__packed__))
56#else
57#define XCB_PACKED
58#endif
59
66
67/* Pre-defined constants */
68
70#define X_PROTOCOL 11
71
73#define X_PROTOCOL_REVISION 0
74
76#define X_TCP_PORT 6000
77
79#define XCB_CONN_ERROR 1
80
82#define XCB_CONN_CLOSED_EXT_NOTSUPPORTED 2
83
85#define XCB_CONN_CLOSED_MEM_INSUFFICIENT 3
86
88#define XCB_CONN_CLOSED_REQ_LEN_EXCEED 4
89
91#define XCB_CONN_CLOSED_PARSE_ERR 5
92
94#define XCB_CONN_CLOSED_INVALID_SCREEN 6
95
97#define XCB_CONN_CLOSED_FDPASSING_FAILED 7
98
99#define XCB_TYPE_PAD(T,I) (-(I) & (sizeof(T) > 4 ? 3 : sizeof(T) - 1))
100
101/* Opaque structures */
102
108 typedef struct xcb_connection_t xcb_connection_t;
109
110
111/* Other types */
112
118 typedef struct {
119 void *data;
120 int rem;
121 int index;
122} xcb_generic_iterator_t;
123
129 typedef struct {
130 uint8_t response_type;
131 uint8_t pad0;
132 uint16_t sequence;
133 uint32_t length;
134} xcb_generic_reply_t;
135
141 typedef struct {
142 uint8_t response_type;
143 uint8_t pad0;
144 uint16_t sequence;
145 uint32_t pad[7];
146 uint32_t full_sequence;
147} xcb_generic_event_t;
148
154 typedef struct {
155 uint8_t response_type;
156 uint8_t pad0;
157 uint16_t sequence;
158 uint32_t pad[7];
159} xcb_raw_generic_event_t;
160
170 typedef struct {
171 uint8_t response_type;
172 uint8_t pad0;
173 uint16_t sequence;
174 uint32_t length;
175 uint16_t event_type;
176 uint16_t pad1;
177 uint32_t pad[5];
178 uint32_t full_sequence;
179} xcb_ge_event_t;
180
186 typedef struct {
187 uint8_t response_type;
188 uint8_t error_code;
189 uint16_t sequence;
190 uint32_t resource_id;
191 uint16_t minor_code;
192 uint8_t major_code;
193 uint8_t pad0;
194 uint32_t pad[5];
195 uint32_t full_sequence;
196} xcb_generic_error_t;
197
203 typedef struct {
204 unsigned int sequence;
205} xcb_void_cookie_t;
206
207
208/* Include the generated xproto header. */
209#include "xproto.h"
210
211
213#define XCB_NONE 0L
214
216#define XCB_COPY_FROM_PARENT 0L
217
219#define XCB_CURRENT_TIME 0L
220
222#define XCB_NO_SYMBOL 0L
223
224
225/* xcb_auth.c */
226
232 typedef struct xcb_auth_info_t {
233 int namelen;
234 char *name;
235 int datalen;
236 char *data;
237} xcb_auth_info_t;
238
239
240/* xcb_out.c */
241
250int xcb_flush(xcb_connection_t *c);
251
267uint32_t xcb_get_maximum_request_length(xcb_connection_t *c);
268
286void xcb_prefetch_maximum_request_length(xcb_connection_t *c);
287
288
289/* xcb_in.c */
290
300 xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c);
301
313 xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c);
314
329 xcb_generic_event_t *xcb_poll_for_queued_event(xcb_connection_t *c);
330
331typedef struct xcb_special_event xcb_special_event_t;
332
336 xcb_generic_event_t *xcb_poll_for_special_event(xcb_connection_t *c,
337 xcb_special_event_t *se);
338
342 xcb_generic_event_t *xcb_wait_for_special_event(xcb_connection_t *c,
343 xcb_special_event_t *se);
347 typedef struct xcb_extension_t xcb_extension_t;
348
352xcb_special_event_t *xcb_register_for_special_xge(xcb_connection_t *c,
353 xcb_extension_t *ext,
354 uint32_t eid,
355 uint32_t *stamp);
356
360void xcb_unregister_for_special_event(xcb_connection_t *c,
361 xcb_special_event_t *se);
362
379 xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie);
380
395void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence);
396
416void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence);
417
418/* xcb_ext.c */
419
436const struct xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
437
449void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
450
451
452/* xcb_conn.c */
453
472const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
473
482int xcb_get_file_descriptor(xcb_connection_t *c);
483
502int xcb_connection_has_error(xcb_connection_t *c);
503
521 xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info);
522
530void xcb_disconnect(xcb_connection_t *c);
531
532
533/* xcb_util.c */
534
552int xcb_parse_display(const char *name, char **host, int *display, int *screen);
553
571 xcb_connection_t *xcb_connect(const char *displayname, int *screenp);
572
590 xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb_auth_info_t *auth, int *screen);
591
592
593/* xcb_xid.c */
594
603uint32_t xcb_generate_id(xcb_connection_t *c);
604
605
616
617uint64_t
618 xcb_total_read(xcb_connection_t *c);
619
631
632uint64_t
633 xcb_total_written(xcb_connection_t *c);
634
638
639#ifdef __cplusplus
640}
641#endif
642
643
644#endif /* __XCB_H__ */
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:792
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:731
xcb_total_written
uint64_t xcb_total_written(xcb_connection_t *c)
Obtain number of bytes written to the connection.
Definition xcb_conn.c:576
xcb_total_read
uint64_t xcb_total_read(xcb_connection_t *c)
Obtain number of bytes read from the connection.
Definition xcb_conn.c:563
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_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:139
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:525
xcb_get_file_descriptor
int xcb_get_file_descriptor(xcb_connection_t *c)
Access the file descriptor of the connection.
Definition xcb_conn.c:340
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:695
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:348
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:643
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:860
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:736
xcb_flush
int xcb_flush(xcb_connection_t *c)
Forces any buffered output to be written to the server.
Definition xcb_out.c:421
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:354
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_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:332
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:162
xcb_discard_reply
void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence)
Discards the reply for a request.
Definition xcb_in.c:629
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_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:777
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:233
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:726
xcb_disconnect
void xcb_disconnect(xcb_connection_t *c)
Closes the connection.
Definition xcb_conn.c:398
xcb_connect
xcb_connection_t * xcb_connect(const char *displayname, int *screenp)
Connects to the X server.
Definition xcb_util.c:520
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:817
xcb_auth_info_t
Container for authorization information.
Definition xcb.h:232
xcb_auth_info_t::namelen
int namelen
Definition xcb.h:233
xcb_auth_info_t::data
char * data
Definition xcb.h:236
xcb_auth_info_t::datalen
int datalen
Definition xcb.h:235
xcb_auth_info_t::name
char * name
Definition xcb.h:234
xcb_connection_t
Definition xcbint.h:208
xcb_extension_t
Definition xcbext.h:39
xcb_ge_event_t
GE event.
Definition xcb.h:170
xcb_ge_event_t::sequence
uint16_t sequence
Definition xcb.h:173
xcb_ge_event_t::pad
uint32_t pad[5]
Definition xcb.h:177
xcb_ge_event_t::full_sequence
uint32_t full_sequence
Definition xcb.h:178
xcb_ge_event_t::response_type
uint8_t response_type
Definition xcb.h:171
xcb_ge_event_t::pad0
uint8_t pad0
Definition xcb.h:172
xcb_generic_error_t
Generic error.
Definition xcb.h:186
xcb_generic_error_t::sequence
uint16_t sequence
Definition xcb.h:189
xcb_generic_error_t::pad0
uint8_t pad0
Definition xcb.h:193
xcb_generic_error_t::pad
uint32_t pad[5]
Definition xcb.h:194
xcb_generic_error_t::minor_code
uint16_t minor_code
Definition xcb.h:191
xcb_generic_error_t::response_type
uint8_t response_type
Definition xcb.h:187
xcb_generic_error_t::major_code
uint8_t major_code
Definition xcb.h:192
xcb_generic_error_t::full_sequence
uint32_t full_sequence
Definition xcb.h:195
xcb_generic_error_t::error_code
uint8_t error_code
Definition xcb.h:188
xcb_generic_event_t
Generic event.
Definition xcb.h:141
xcb_generic_event_t::full_sequence
uint32_t full_sequence
Definition xcb.h:146
xcb_generic_event_t::sequence
uint16_t sequence
Definition xcb.h:144
xcb_generic_event_t::pad
uint32_t pad[7]
Definition xcb.h:145
xcb_generic_event_t::pad0
uint8_t pad0
Definition xcb.h:143
xcb_generic_event_t::response_type
uint8_t response_type
Definition xcb.h:142
xcb_generic_iterator_t
Generic iterator.
Definition xcb.h:118
xcb_generic_iterator_t::rem
int rem
Definition xcb.h:120
xcb_generic_iterator_t::data
void * data
Definition xcb.h:119
xcb_generic_iterator_t::index
int index
Definition xcb.h:121
xcb_generic_reply_t
Generic reply.
Definition xcb.h:129
xcb_generic_reply_t::length
uint32_t length
Definition xcb.h:133
xcb_generic_reply_t::response_type
uint8_t response_type
Definition xcb.h:130
xcb_generic_reply_t::sequence
uint16_t sequence
Definition xcb.h:132
xcb_generic_reply_t::pad0
uint8_t pad0
Definition xcb.h:131
xcb_query_extension_reply_t
xcb_query_extension_reply_t
Definition xproto.h:4287
xcb_raw_generic_event_t
Raw Generic event.
Definition xcb.h:154
xcb_raw_generic_event_t::pad0
uint8_t pad0
Definition xcb.h:156
xcb_raw_generic_event_t::response_type
uint8_t response_type
Definition xcb.h:155
xcb_raw_generic_event_t::pad
uint32_t pad[7]
Definition xcb.h:158
xcb_raw_generic_event_t::sequence
uint16_t sequence
Definition xcb.h:157
xcb_setup_t
xcb_setup_t
Definition xproto.h:475
xcb_special_event
Definition xcb_in.c:64
xcb_void_cookie_t
Generic cookie.
Definition xcb.h:203
xcb_void_cookie_t::sequence
unsigned int sequence
Definition xcb.h:204