Warning: That file was not part of the compilation database. It may have many parsing errors.

1
2/*
3
4Copyright 1984, 1985, 1987, 1989, 1998 The Open Group
5
6Permission to use, copy, modify, distribute, and sell this software and its
7documentation for any purpose is hereby granted without fee, provided that
8the above copyright notice appear in all copies and that both that
9copyright notice and this permission notice appear in supporting
10documentation.
11
12The above copyright notice and this permission notice shall be included
13in all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of The Open Group shall
24not be used in advertising or otherwise to promote the sale, use or
25other dealings in this Software without prior written authorization
26from The Open Group.
27
28*/
29
30#ifndef _X11_XLIBINT_H_
31#define _X11_XLIBINT_H_ 1
32
33/*
34 * Xlibint.h - Header definition and support file for the internal
35 * support routines used by the C subroutine interface
36 * library (Xlib) to the X Window System.
37 *
38 * Warning, there be dragons here....
39 */
40
41#include <X11/Xlib.h>
42#include <X11/Xproto.h> /* to declare xEvent */
43#include <X11/XlibConf.h> /* for configured options like XTHREADS */
44
45/* The Xlib structs are full of implicit padding to properly align members.
46 We can't clean that up without breaking ABI, so tell clang not to bother
47 complaining about it. */
48#ifdef __clang__
49#pragma clang diagnostic push
50#pragma clang diagnostic ignored "-Wpadded"
51#endif
52
53#ifdef WIN32
54#define _XFlush _XFlushIt
55#endif
56
57/*
58 * If your BytesReadable correctly detects broken connections, then
59 * you should NOT define XCONN_CHECK_FREQ.
60 */
61#ifndef XCONN_CHECK_FREQ
62#define XCONN_CHECK_FREQ 256
63#endif
64
65struct _XGC
66{
67 XExtData *ext_data; /* hook for extension to hang data */
68 GContext gid; /* protocol ID for graphics context */
69 Bool rects; /* boolean: TRUE if clipmask is list of rectangles */
70 Bool dashes; /* boolean: TRUE if dash-list is really a list */
71 unsigned long dirty;/* cache dirty bits */
72 XGCValues values; /* shadow structure of values */
73};
74
75struct _XDisplay
76{
77 XExtData *ext_data; /* hook for extension to hang data */
78 struct _XFreeFuncs *free_funcs; /* internal free functions */
79 int fd; /* Network socket. */
80 int conn_checker; /* ugly thing used by _XEventsQueued */
81 int proto_major_version;/* maj. version of server's X protocol */
82 int proto_minor_version;/* minor version of server's X protocol */
83 char *vendor; /* vendor of the server hardware */
84 XID resource_base; /* resource ID base */
85 XID resource_mask; /* resource ID mask bits */
86 XID resource_id; /* allocator current ID */
87 int resource_shift; /* allocator shift to correct bits */
88 XID (*resource_alloc)( /* allocator function */
89 struct _XDisplay*
90 );
91 int byte_order; /* screen byte order, LSBFirst, MSBFirst */
92 int bitmap_unit; /* padding and data requirements */
93 int bitmap_pad; /* padding requirements on bitmaps */
94 int bitmap_bit_order; /* LeastSignificant or MostSignificant */
95 int nformats; /* number of pixmap formats in list */
96 ScreenFormat *pixmap_format; /* pixmap format list */
97 int vnumber; /* Xlib's X protocol version number. */
98 int release; /* release of the server */
99 struct _XSQEvent *head, *tail; /* Input event queue. */
100 int qlen; /* Length of input event queue */
101 unsigned long last_request_read; /* seq number of last event read */
102 unsigned long request; /* sequence number of last request. */
103 char *last_req; /* beginning of last request, or dummy */
104 char *buffer; /* Output buffer starting address. */
105 char *bufptr; /* Output buffer index pointer. */
106 char *bufmax; /* Output buffer maximum+1 address. */
107 unsigned max_request_size; /* maximum number 32 bit words in request*/
108 struct _XrmHashBucketRec *db;
109 int (*synchandler)( /* Synchronization handler */
110 struct _XDisplay*
111 );
112 char *display_name; /* "host:display" string used on this connect*/
113 int default_screen; /* default screen for operations */
114 int nscreens; /* number of screens on this server*/
115 Screen *screens; /* pointer to list of screens */
116 unsigned long motion_buffer; /* size of motion buffer */
117 volatile unsigned long flags; /* internal connection flags */
118 int min_keycode; /* minimum defined keycode */
119 int max_keycode; /* maximum defined keycode */
120 KeySym *keysyms; /* This server's keysyms */
121 XModifierKeymap *modifiermap; /* This server's modifier keymap */
122 int keysyms_per_keycode;/* number of rows */
123 char *xdefaults; /* contents of defaults from server */
124 char *scratch_buffer; /* place to hang scratch buffer */
125 unsigned long scratch_length; /* length of scratch buffer */
126 int ext_number; /* extension number on this display */
127 struct _XExten *ext_procs; /* extensions initialized on this display */
128 /*
129 * the following can be fixed size, as the protocol defines how
130 * much address space is available.
131 * While this could be done using the extension vector, there
132 * may be MANY events processed, so a search through the extension
133 * list to find the right procedure for each event might be
134 * expensive if many extensions are being used.
135 */
136 Bool (*event_vec[128])( /* vector for wire to event */
137 Display * /* dpy */,
138 XEvent * /* re */,
139 xEvent * /* event */
140 );
141 Status (*wire_vec[128])( /* vector for event to wire */
142 Display * /* dpy */,
143 XEvent * /* re */,
144 xEvent * /* event */
145 );
146 KeySym lock_meaning; /* for XLookupString */
147 struct _XLockInfo *lock; /* multi-thread state, display lock */
148 struct _XInternalAsync *async_handlers; /* for internal async */
149 unsigned long bigreq_size; /* max size of big requests */
150 struct _XLockPtrs *lock_fns; /* pointers to threads functions */
151 void (*idlist_alloc)( /* XID list allocator function */
152 Display * /* dpy */,
153 XID * /* ids */,
154 int /* count */
155 );
156 /* things above this line should not move, for binary compatibility */
157 struct _XKeytrans *key_bindings; /* for XLookupString */
158 Font cursor_font; /* for XCreateFontCursor */
159 struct _XDisplayAtoms *atoms; /* for XInternAtom */
160 unsigned int mode_switch; /* keyboard group modifiers */
161 unsigned int num_lock; /* keyboard numlock modifiers */
162 struct _XContextDB *context_db; /* context database */
163 Bool (**error_vec)( /* vector for wire to error */
164 Display * /* display */,
165 XErrorEvent * /* he */,
166 xError * /* we */
167 );
168 /*
169 * Xcms information
170 */
171 struct {
172 XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */
173 XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */
174 XPointer perVisualIntensityMaps;
175 /* linked list of XcmsIntensityMap */
176 } cms;
177 struct _XIMFilter *im_filters;
178 struct _XSQEvent *qfree; /* unallocated event queue elements */
179 unsigned long next_event_serial_num; /* inserted into next queue elt */
180 struct _XExten *flushes; /* Flush hooks */
181 struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */
182 int im_fd_length; /* number of im_fd_info */
183 struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */
184 int watcher_count; /* number of conn_watchers */
185 XPointer filedes; /* struct pollfd cache for _XWaitForReadable */
186 int (*savedsynchandler)( /* user synchandler when Xlib usurps */
187 Display * /* dpy */
188 );
189 XID resource_max; /* allocator max ID */
190 int xcmisc_opcode; /* major opcode for XC-MISC */
191 struct _XkbInfoRec *xkb_info; /* XKB info */
192 struct _XtransConnInfo *trans_conn; /* transport connection object */
193 struct _X11XCBPrivate *xcb; /* XCB glue private data */
194
195 /* Generic event cookie handling */
196 unsigned int next_cookie; /* next event cookie */
197 /* vector for wire to generic event, index is (extension - 128) */
198 Bool (*generic_event_vec[128])(
199 Display * /* dpy */,
200 XGenericEventCookie * /* Xlib event */,
201 xEvent * /* wire event */);
202 /* vector for event copy, index is (extension - 128) */
203 Bool (*generic_event_copy_vec[128])(
204 Display * /* dpy */,
205 XGenericEventCookie * /* in */,
206 XGenericEventCookie * /* out*/);
207 void *cookiejar; /* cookie events returned but not claimed */
208};
209
210#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
211
212#ifndef _XEVENT_
213/*
214 * _QEvent datatype for use in input queueing.
215 */
216typedef struct _XSQEvent
217{
218 struct _XSQEvent *next;
219 XEvent event;
220 unsigned long qserial_num; /* so multi-threaded code can find new ones */
221} _XQEvent;
222#endif
223
224#include <X11/Xproto.h>
225#ifdef __sgi
226#define _SGI_MP_SOURCE /* turn this on to get MP safe errno */
227#endif
228#include <errno.h>
229#define _XBCOPYFUNC _Xbcopy
230#include <X11/Xfuncs.h>
231#include <X11/Xosdefs.h>
232
233/* Utek leaves kernel macros around in include files (bleah) */
234#ifdef dirty
235#undef dirty
236#endif
237
238#include <stdlib.h>
239#include <string.h>
240
241#include <X11/Xfuncproto.h>
242
243_XFUNCPROTOBEGIN
244
245/*
246 * The following definitions can be used for locking requests in multi-threaded
247 * address spaces.
248 */
249#ifdef XTHREADS
250/* Author: Stephen Gildea, MIT X Consortium
251 *
252 * declarations for C Threads locking
253 */
254
255typedef struct _LockInfoRec *LockInfoPtr;
256
257/* interfaces for locking.c */
258struct _XLockPtrs {
259 /* used by all, including extensions; do not move */
260 void (*lock_display)(
261 Display *dpy
262#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
263 , char *file
264 , int line
265#endif
266 );
267 void (*unlock_display)(
268 Display *dpy
269#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
270 , char *file
271 , int line
272#endif
273 );
274};
275
276#if defined(WIN32) && !defined(_XLIBINT_)
277#define _XCreateMutex_fn (*_XCreateMutex_fn_p)
278#define _XFreeMutex_fn (*_XFreeMutex_fn_p)
279#define _XLockMutex_fn (*_XLockMutex_fn_p)
280#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)
281#define _Xglobal_lock (*_Xglobal_lock_p)
282#endif
283
284/* in XlibInt.c */
285extern void (*_XCreateMutex_fn)(
286 LockInfoPtr /* lock */
287);
288extern void (*_XFreeMutex_fn)(
289 LockInfoPtr /* lock */
290);
291extern void (*_XLockMutex_fn)(
292 LockInfoPtr /* lock */
293#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
294 , char * /* file */
295 , int /* line */
296#endif
297);
298extern void (*_XUnlockMutex_fn)(
299 LockInfoPtr /* lock */
300#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
301 , char * /* file */
302 , int /* line */
303#endif
304);
305
306extern LockInfoPtr _Xglobal_lock;
307
308#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
309#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)
310#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)
311#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)
312#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)
313#else
314/* used everywhere, so must be fast if not using threads */
315#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)
316#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)
317#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)
318#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)
319#endif
320#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);
321#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);
322
323#else /* XTHREADS */
324#define LockDisplay(dis)
325#define _XLockMutex(lock)
326#define _XUnlockMutex(lock)
327#define UnlockDisplay(dis)
328#define _XCreateMutex(lock)
329#define _XFreeMutex(lock)
330#endif
331
332#define Xfree(ptr) free((ptr))
333
334/*
335 * Note that some machines do not return a valid pointer for malloc(0), in
336 * which case we provide an alternate under the control of the
337 * define MALLOC_0_RETURNS_NULL. This is necessary because some
338 * Xlib code expects malloc(0) to return a valid pointer to storage.
339 */
340#if defined(MALLOC_0_RETURNS_NULL) || defined(__clang_analyzer__)
341
342# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
343# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
344# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))
345
346#else
347
348# define Xmalloc(size) malloc((size))
349# define Xrealloc(ptr, size) realloc((ptr), (size))
350# define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
351
352#endif
353
354#include <stddef.h>
355
356#define LOCKED 1
357#define UNLOCKED 0
358
359#ifndef BUFSIZE
360#define BUFSIZE 2048 /* X output buffer size. */
361#endif
362#ifndef PTSPERBATCH
363#define PTSPERBATCH 1024 /* point batching */
364#endif
365#ifndef WLNSPERBATCH
366#define WLNSPERBATCH 50 /* wide line batching */
367#endif
368#ifndef ZLNSPERBATCH
369#define ZLNSPERBATCH 1024 /* thin line batching */
370#endif
371#ifndef WRCTSPERBATCH
372#define WRCTSPERBATCH 10 /* wide line rectangle batching */
373#endif
374#ifndef ZRCTSPERBATCH
375#define ZRCTSPERBATCH 256 /* thin line rectangle batching */
376#endif
377#ifndef FRCTSPERBATCH
378#define FRCTSPERBATCH 256 /* filled rectangle batching */
379#endif
380#ifndef FARCSPERBATCH
381#define FARCSPERBATCH 256 /* filled arc batching */
382#endif
383#ifndef CURSORFONT
384#define CURSORFONT "cursor" /* standard cursor fonts */
385#endif
386
387/*
388 * Display flags
389 */
390#define XlibDisplayIOError (1L << 0)
391#define XlibDisplayClosing (1L << 1)
392#define XlibDisplayNoXkb (1L << 2)
393#define XlibDisplayPrivSync (1L << 3)
394#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */
395#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */
396#define XlibDisplayReply (1L << 5) /* in _XReply */
397#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */
398#define XlibDisplayDfltRMDB (1L << 7) /* mark if RM db from XGetDefault */
399
400/*
401 * X Protocol packetizing macros.
402 */
403
404/* Leftover from CRAY support - was defined empty on all non-Cray systems */
405#define WORD64ALIGN
406
407/**
408 * Return a len-sized request buffer for the request type. This function may
409 * flush the output queue.
410 *
411 * @param dpy The display connection
412 * @param type The request type
413 * @param len Length of the request in bytes
414 *
415 * @returns A pointer to the request buffer with a few default values
416 * initialized.
417 */
418extern void *_XGetRequest(Display *dpy, CARD8 type, size_t len);
419
420/* GetReqSized is the same as GetReq but allows the caller to specify the
421 * size in bytes. 'sz' must be a multiple of 4! */
422
423#define GetReqSized(name, sz, req) \
424 req = (x##name##Req *) _XGetRequest(dpy, X_##name, sz)
425
426/*
427 * GetReq - Get the next available X request packet in the buffer and
428 * return it.
429 *
430 * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
431 * "req" is the name of the request pointer.
432 *
433 */
434
435#define GetReq(name, req) \
436 GetReqSized(name, SIZEOF(x##name##Req), req)
437
438/* GetReqExtra is the same as GetReq, but allocates "n" additional
439 bytes after the request. "n" must be a multiple of 4! */
440
441#define GetReqExtra(name, n, req) \
442 GetReqSized(name, SIZEOF(x##name##Req) + n, req)
443
444/*
445 * GetResReq is for those requests that have a resource ID
446 * (Window, Pixmap, GContext, etc.) as their single argument.
447 * "rid" is the name of the resource.
448 */
449
450#define GetResReq(name, rid, req) \
451 req = (xResourceReq *) _XGetRequest(dpy, X_##name, SIZEOF(xResourceReq)); \
452 req->id = (rid)
453
454/*
455 * GetEmptyReq is for those requests that have no arguments
456 * at all.
457 */
458
459#define GetEmptyReq(name, req) \
460 req = (xReq *) _XGetRequest(dpy, X_##name, SIZEOF(xReq))
461
462/*
463 * MakeBigReq sets the CARD16 "req->length" to 0 and inserts a new CARD32
464 * length, after req->length, before the data in the request. The new length
465 * includes the "n" extra 32-bit words.
466 *
467 * Do not use MakeBigReq if there is no data already in the request.
468 * req->length must already be >= 2.
469 */
470#ifdef LONG64
471#define MakeBigReq(req,n) \
472 { \
473 CARD64 _BRdat; \
474 CARD32 _BRlen = req->length - 1; \
475 req->length = 0; \
476 _BRdat = ((CARD32 *)req)[_BRlen]; \
477 memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \
478 ((CARD32 *)req)[1] = _BRlen + n + 2; \
479 Data32(dpy, &_BRdat, 4); \
480 }
481#else
482#define MakeBigReq(req,n) \
483 { \
484 CARD32 _BRdat; \
485 CARD32 _BRlen = req->length - 1; \
486 req->length = 0; \
487 _BRdat = ((CARD32 *)req)[_BRlen]; \
488 memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \
489 ((CARD32 *)req)[1] = _BRlen + n + 2; \
490 Data32(dpy, &_BRdat, 4); \
491 }
492#endif
493
494/*
495 * SetReqLen increases the count of 32-bit words in the request by "n",
496 * or by "badlen" if "n" is too large.
497 *
498 * Do not use SetReqLen if "req" does not already have data after the
499 * xReq header. req->length must already be >= 2.
500 */
501#ifndef __clang_analyzer__
502#define SetReqLen(req,n,badlen) \
503 if ((req->length + n) > (unsigned)65535) { \
504 if (dpy->bigreq_size) { \
505 MakeBigReq(req,n) \
506 } else { \
507 n = badlen; \
508 req->length += n; \
509 } \
510 } else \
511 req->length += n
512#else
513#define SetReqLen(req,n,badlen) \
514 req->length += n
515#endif
516
517#define SyncHandle() \
518 if (dpy->synchandler) (*dpy->synchandler)(dpy)
519
520extern void _XFlushGCCache(Display *dpy, GC gc);
521#define FlushGC(dpy, gc) \
522 if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
523/*
524 * Data - Place data in the buffer and pad the end to provide
525 * 32 bit word alignment. Transmit if the buffer fills.
526 *
527 * "dpy" is a pointer to a Display.
528 * "data" is a pointer to a data buffer.
529 * "len" is the length of the data buffer.
530 */
531#ifndef DataRoutineIsProcedure
532#define Data(dpy, data, len) {\
533 if (dpy->bufptr + (len) <= dpy->bufmax) {\
534 memcpy(dpy->bufptr, data, (int)len);\
535 dpy->bufptr += ((len) + 3) & ~3;\
536 } else\
537 _XSend(dpy, data, len);\
538}
539#endif /* DataRoutineIsProcedure */
540
541
542/* Allocate bytes from the buffer. No padding is done, so if
543 * the length is not a multiple of 4, the caller must be
544 * careful to leave the buffer aligned after sending the
545 * current request.
546 *
547 * "type" is the type of the pointer being assigned to.
548 * "ptr" is the pointer being assigned to.
549 * "n" is the number of bytes to allocate.
550 *
551 * Example:
552 * xTextElt *elt;
553 * BufAlloc (xTextElt *, elt, nbytes)
554 */
555
556#define BufAlloc(type, ptr, n) \
557 if (dpy->bufptr + (n) > dpy->bufmax) \
558 _XFlush (dpy); \
559 ptr = (type) dpy->bufptr; \
560 memset(ptr, '\0', n); \
561 dpy->bufptr += (n);
562
563#define Data16(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
564#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
565#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
566#ifdef LONG64
567#define Data32(dpy, data, len) _XData32(dpy, (_Xconst long *)data, len)
568extern int _XData32(
569 Display *dpy,
570 register _Xconst long *data,
571 unsigned len
572);
573extern void _XRead32(
574 Display *dpy,
575 register long *data,
576 long len
577);
578#else
579#define Data32(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
580#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
581#endif
582
583#define PackData16(dpy,data,len) Data16 (dpy, data, len)
584#define PackData32(dpy,data,len) Data32 (dpy, data, len)
585
586/* Xlib manual is bogus */
587#define PackData(dpy,data,len) PackData16 (dpy, data, len)
588
589#define min(a,b) (((a) < (b)) ? (a) : (b))
590#define max(a,b) (((a) > (b)) ? (a) : (b))
591
592#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
593 (((cs)->rbearing|(cs)->lbearing| \
594 (cs)->ascent|(cs)->descent) == 0))
595
596/*
597 * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit
598 * character. If the character is in the column and exists, then return the
599 * appropriate metrics (note that fonts with common per-character metrics will
600 * return min_bounds). If none of these hold true, try again with the default
601 * char.
602 */
603#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
604{ \
605 cs = def; \
606 if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
607 if (fs->per_char == NULL) { \
608 cs = &fs->min_bounds; \
609 } else { \
610 cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
611 if (CI_NONEXISTCHAR(cs)) cs = def; \
612 } \
613 } \
614}
615
616#define CI_GET_DEFAULT_INFO_1D(fs,cs) \
617 CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
618
619
620
621/*
622 * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and
623 * column. This is used for fonts that have more than row zero.
624 */
625#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
626{ \
627 cs = def; \
628 if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
629 col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
630 if (fs->per_char == NULL) { \
631 cs = &fs->min_bounds; \
632 } else { \
633 cs = &fs->per_char[((row - fs->min_byte1) * \
634 (fs->max_char_or_byte2 - \
635 fs->min_char_or_byte2 + 1)) + \
636 (col - fs->min_char_or_byte2)]; \
637 if (CI_NONEXISTCHAR(cs)) cs = def; \
638 } \
639 } \
640}
641
642#define CI_GET_DEFAULT_INFO_2D(fs,cs) \
643{ \
644 unsigned int r = (fs->default_char >> 8); \
645 unsigned int c = (fs->default_char & 0xff); \
646 CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
647}
648
649
650/* srcvar must be a variable for large architecture version */
651#define OneDataCard32(dpy,dstaddr,srcvar) \
652 { *(CARD32 *)(dstaddr) = (srcvar); }
653
654
655typedef struct _XInternalAsync {
656 struct _XInternalAsync *next;
657 /*
658 * handler arguments:
659 * rep is the generic reply that caused this handler
660 * to be invoked. It must also be passed to _XGetAsyncReply.
661 * buf and len are opaque values that must be passed to
662 * _XGetAsyncReply or _XGetAsyncData.
663 * data is the closure stored in this struct.
664 * The handler returns True iff it handled this reply.
665 */
666 Bool (*handler)(
667 Display* /* dpy */,
668 xReply* /* rep */,
669 char* /* buf */,
670 int /* len */,
671 XPointer /* data */
672 );
673 XPointer data;
674} _XAsyncHandler;
675
676typedef struct _XAsyncEState {
677 unsigned long min_sequence_number;
678 unsigned long max_sequence_number;
679 unsigned char error_code;
680 unsigned char major_opcode;
681 unsigned short minor_opcode;
682 unsigned char last_error_received;
683 int error_count;
684} _XAsyncErrorState;
685
686extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler);
687#define DeqAsyncHandler(dpy,handler) { \
688 if (dpy->async_handlers == (handler)) \
689 dpy->async_handlers = (handler)->next; \
690 else \
691 _XDeqAsyncHandler(dpy, handler); \
692 }
693
694typedef void (*FreeFuncType) (
695 Display* /* display */
696);
697
698typedef int (*FreeModmapType) (
699 XModifierKeymap* /* modmap */
700);
701
702/*
703 * This structure is private to the library.
704 */
705typedef struct _XFreeFuncs {
706 FreeFuncType atoms; /* _XFreeAtomTable */
707 FreeModmapType modifiermap; /* XFreeModifiermap */
708 FreeFuncType key_bindings; /* _XFreeKeyBindings */
709 FreeFuncType context_db; /* _XFreeContextDB */
710 FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */
711 FreeFuncType clientCmaps; /* _XcmsFreeClientCmaps */
712 FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */
713 FreeFuncType im_filters; /* _XFreeIMFilters */
714 FreeFuncType xkb; /* _XkbFreeInfo */
715} _XFreeFuncRec;
716
717/* types for InitExt.c */
718typedef int (*CreateGCType) (
719 Display* /* display */,
720 GC /* gc */,
721 XExtCodes* /* codes */
722);
723
724typedef int (*CopyGCType)(
725 Display* /* display */,
726 GC /* gc */,
727 XExtCodes* /* codes */
728);
729
730typedef int (*FlushGCType) (
731 Display* /* display */,
732 GC /* gc */,
733 XExtCodes* /* codes */
734);
735
736typedef int (*FreeGCType) (
737 Display* /* display */,
738 GC /* gc */,
739 XExtCodes* /* codes */
740);
741
742typedef int (*CreateFontType) (
743 Display* /* display */,
744 XFontStruct* /* fs */,
745 XExtCodes* /* codes */
746);
747
748typedef int (*FreeFontType) (
749 Display* /* display */,
750 XFontStruct* /* fs */,
751 XExtCodes* /* codes */
752);
753
754typedef int (*CloseDisplayType) (
755 Display* /* display */,
756 XExtCodes* /* codes */
757);
758
759typedef int (*ErrorType) (
760 Display* /* display */,
761 xError* /* err */,
762 XExtCodes* /* codes */,
763 int* /* ret_code */
764);
765
766typedef char* (*ErrorStringType) (
767 Display* /* display */,
768 int /* code */,
769 XExtCodes* /* codes */,
770 char* /* buffer */,
771 int /* nbytes */
772);
773
774typedef void (*PrintErrorType)(
775 Display* /* display */,
776 XErrorEvent* /* ev */,
777 void* /* fp */
778);
779
780typedef void (*BeforeFlushType)(
781 Display* /* display */,
782 XExtCodes* /* codes */,
783 _Xconst char* /* data */,
784 long /* len */
785);
786
787/*
788 * This structure is private to the library.
789 */
790typedef struct _XExten { /* private to extension mechanism */
791 struct _XExten *next; /* next in list */
792 XExtCodes codes; /* public information, all extension told */
793 CreateGCType create_GC; /* routine to call when GC created */
794 CopyGCType copy_GC; /* routine to call when GC copied */
795 FlushGCType flush_GC; /* routine to call when GC flushed */
796 FreeGCType free_GC; /* routine to call when GC freed */
797 CreateFontType create_Font; /* routine to call when Font created */
798 FreeFontType free_Font; /* routine to call when Font freed */
799 CloseDisplayType close_display; /* routine to call when connection closed */
800 ErrorType error; /* who to call when an error occurs */
801 ErrorStringType error_string; /* routine to supply error string */
802 char *name; /* name of this extension */
803 PrintErrorType error_values; /* routine to supply error values */
804 BeforeFlushType before_flush; /* routine to call when sending data */
805 struct _XExten *next_flush; /* next in list of those with flushes */
806} _XExtension;
807
808/* Temporary definition until we can depend on an xproto release with it */
809#ifdef _X_COLD
810# define _XLIB_COLD _X_COLD
811#elif defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403) /* 4.3+ */
812# define _XLIB_COLD __attribute__((__cold__))
813#else
814# define _XLIB_COLD /* nothing */
815#endif
816
817/* extension hooks */
818
819#ifdef DataRoutineIsProcedure
820extern void Data(Display *dpy, char *data, long len);
821#endif
822extern int _XError(
823 Display* /* dpy */,
824 xError* /* rep */
825);
826extern int _XIOError(
827 Display* /* dpy */
828) _X_NORETURN;
829extern int (*_XIOErrorFunction)(
830 Display* /* dpy */
831);
832extern int (*_XErrorFunction)(
833 Display* /* dpy */,
834 XErrorEvent* /* error_event */
835);
836extern void _XEatData(
837 Display* /* dpy */,
838 unsigned long /* n */
839) _XLIB_COLD;
840extern void _XEatDataWords(
841 Display* /* dpy */,
842 unsigned long /* n */
843) _XLIB_COLD;
844#if defined(__SUNPRO_C) /* Studio compiler alternative to "cold" attribute */
845# pragma rarely_called(_XEatData, _XEatDataWords)
846#endif
847extern char *_XAllocScratch(
848 Display* /* dpy */,
849 unsigned long /* nbytes */
850);
851extern char *_XAllocTemp(
852 Display* /* dpy */,
853 unsigned long /* nbytes */
854);
855extern void _XFreeTemp(
856 Display* /* dpy */,
857 char* /* buf */,
858 unsigned long /* nbytes */
859);
860extern Visual *_XVIDtoVisual(
861 Display* /* dpy */,
862 VisualID /* id */
863);
864extern unsigned long _XSetLastRequestRead(
865 Display* /* dpy */,
866 xGenericReply* /* rep */
867);
868extern int _XGetHostname(
869 char* /* buf */,
870 int /* maxlen */
871);
872extern Screen *_XScreenOfWindow(
873 Display* /* dpy */,
874 Window /* w */
875);
876extern Bool _XAsyncErrorHandler(
877 Display* /* dpy */,
878 xReply* /* rep */,
879 char* /* buf */,
880 int /* len */,
881 XPointer /* data */
882);
883extern char *_XGetAsyncReply(
884 Display* /* dpy */,
885 char* /* replbuf */,
886 xReply* /* rep */,
887 char* /* buf */,
888 int /* len */,
889 int /* extra */,
890 Bool /* discard */
891);
892extern void _XGetAsyncData(
893 Display* /* dpy */,
894 char * /* data */,
895 char * /* buf */,
896 int /* len */,
897 int /* skip */,
898 int /* datalen */,
899 int /* discardtotal */
900);
901extern void _XFlush(
902 Display* /* dpy */
903);
904extern int _XEventsQueued(
905 Display* /* dpy */,
906 int /* mode */
907);
908extern void _XReadEvents(
909 Display* /* dpy */
910);
911extern int _XRead(
912 Display* /* dpy */,
913 char* /* data */,
914 long /* size */
915);
916extern void _XReadPad(
917 Display* /* dpy */,
918 char* /* data */,
919 long /* size */
920);
921extern void _XSend(
922 Display* /* dpy */,
923 _Xconst char* /* data */,
924 long /* size */
925);
926extern Status _XReply(
927 Display* /* dpy */,
928 xReply* /* rep */,
929 int /* extra */,
930 Bool /* discard */
931);
932extern void _XEnq(
933 Display* /* dpy */,
934 xEvent* /* event */
935);
936extern void _XDeq(
937 Display* /* dpy */,
938 _XQEvent* /* prev */,
939 _XQEvent* /* qelt */
940);
941
942extern Bool _XUnknownWireEvent(
943 Display* /* dpy */,
944 XEvent* /* re */,
945 xEvent* /* event */
946);
947
948extern Bool _XUnknownWireEventCookie(
949 Display* /* dpy */,
950 XGenericEventCookie* /* re */,
951 xEvent* /* event */
952);
953
954extern Bool _XUnknownCopyEventCookie(
955 Display* /* dpy */,
956 XGenericEventCookie* /* in */,
957 XGenericEventCookie* /* out */
958);
959
960extern Status _XUnknownNativeEvent(
961 Display* /* dpy */,
962 XEvent* /* re */,
963 xEvent* /* event */
964);
965
966extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event);
967extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we);
968extern Bool _XPollfdCacheInit(Display *dpy);
969extern void _XPollfdCacheAdd(Display *dpy, int fd);
970extern void _XPollfdCacheDel(Display *dpy, int fd);
971extern XID _XAllocID(Display *dpy);
972extern void _XAllocIDs(Display *dpy, XID *ids, int count);
973
974extern int _XFreeExtData(
975 XExtData* /* extension */
976);
977
978extern int (*XESetCreateGC(
979 Display* /* display */,
980 int /* extension */,
981 int (*) (
982 Display* /* display */,
983 GC /* gc */,
984 XExtCodes* /* codes */
985 ) /* proc */
986))(
987 Display*, GC, XExtCodes*
988);
989
990extern int (*XESetCopyGC(
991 Display* /* display */,
992 int /* extension */,
993 int (*) (
994 Display* /* display */,
995 GC /* gc */,
996 XExtCodes* /* codes */
997 ) /* proc */
998))(
999 Display*, GC, XExtCodes*
1000);
1001
1002extern int (*XESetFlushGC(
1003 Display* /* display */,
1004 int /* extension */,
1005 int (*) (
1006 Display* /* display */,
1007 GC /* gc */,
1008 XExtCodes* /* codes */
1009 ) /* proc */
1010))(
1011 Display*, GC, XExtCodes*
1012);
1013
1014extern int (*XESetFreeGC(
1015 Display* /* display */,
1016 int /* extension */,
1017 int (*) (
1018 Display* /* display */,
1019 GC /* gc */,
1020 XExtCodes* /* codes */
1021 ) /* proc */
1022))(
1023 Display*, GC, XExtCodes*
1024);
1025
1026extern int (*XESetCreateFont(
1027 Display* /* display */,
1028 int /* extension */,
1029 int (*) (
1030 Display* /* display */,
1031 XFontStruct* /* fs */,
1032 XExtCodes* /* codes */
1033 ) /* proc */
1034))(
1035 Display*, XFontStruct*, XExtCodes*
1036);
1037
1038extern int (*XESetFreeFont(
1039 Display* /* display */,
1040 int /* extension */,
1041 int (*) (
1042 Display* /* display */,
1043 XFontStruct* /* fs */,
1044 XExtCodes* /* codes */
1045 ) /* proc */
1046))(
1047 Display*, XFontStruct*, XExtCodes*
1048);
1049
1050extern int (*XESetCloseDisplay(
1051 Display* /* display */,
1052 int /* extension */,
1053 int (*) (
1054 Display* /* display */,
1055 XExtCodes* /* codes */
1056 ) /* proc */
1057))(
1058 Display*, XExtCodes*
1059);
1060
1061extern int (*XESetError(
1062 Display* /* display */,
1063 int /* extension */,
1064 int (*) (
1065 Display* /* display */,
1066 xError* /* err */,
1067 XExtCodes* /* codes */,
1068 int* /* ret_code */
1069 ) /* proc */
1070))(
1071 Display*, xError*, XExtCodes*, int*
1072);
1073
1074extern char* (*XESetErrorString(
1075 Display* /* display */,
1076 int /* extension */,
1077 char* (*) (
1078 Display* /* display */,
1079 int /* code */,
1080 XExtCodes* /* codes */,
1081 char* /* buffer */,
1082 int /* nbytes */
1083 ) /* proc */
1084))(
1085 Display*, int, XExtCodes*, char*, int
1086);
1087
1088extern void (*XESetPrintErrorValues (
1089 Display* /* display */,
1090 int /* extension */,
1091 void (*)(
1092 Display* /* display */,
1093 XErrorEvent* /* ev */,
1094 void* /* fp */
1095 ) /* proc */
1096))(
1097 Display*, XErrorEvent*, void*
1098);
1099
1100extern Bool (*XESetWireToEvent(
1101 Display* /* display */,
1102 int /* event_number */,
1103 Bool (*) (
1104 Display* /* display */,
1105 XEvent* /* re */,
1106 xEvent* /* event */
1107 ) /* proc */
1108))(
1109 Display*, XEvent*, xEvent*
1110);
1111
1112extern Bool (*XESetWireToEventCookie(
1113 Display* /* display */,
1114 int /* extension */,
1115 Bool (*) (
1116 Display* /* display */,
1117 XGenericEventCookie* /* re */,
1118 xEvent* /* event */
1119 ) /* proc */
1120))(
1121 Display*, XGenericEventCookie*, xEvent*
1122);
1123
1124extern Bool (*XESetCopyEventCookie(
1125 Display* /* display */,
1126 int /* extension */,
1127 Bool (*) (
1128 Display* /* display */,
1129 XGenericEventCookie* /* in */,
1130 XGenericEventCookie* /* out */
1131 ) /* proc */
1132))(
1133 Display*, XGenericEventCookie*, XGenericEventCookie*
1134);
1135
1136
1137extern Status (*XESetEventToWire(
1138 Display* /* display */,
1139 int /* event_number */,
1140 Status (*) (
1141 Display* /* display */,
1142 XEvent* /* re */,
1143 xEvent* /* event */
1144 ) /* proc */
1145))(
1146 Display*, XEvent*, xEvent*
1147);
1148
1149extern Bool (*XESetWireToError(
1150 Display* /* display */,
1151 int /* error_number */,
1152 Bool (*) (
1153 Display* /* display */,
1154 XErrorEvent* /* he */,
1155 xError* /* we */
1156 ) /* proc */
1157))(
1158 Display*, XErrorEvent*, xError*
1159);
1160
1161extern void (*XESetBeforeFlush(
1162 Display* /* display */,
1163 int /* error_number */,
1164 void (*) (
1165 Display* /* display */,
1166 XExtCodes* /* codes */,
1167 _Xconst char* /* data */,
1168 long /* len */
1169 ) /* proc */
1170))(
1171 Display*, XExtCodes*, _Xconst char*, long
1172);
1173
1174/* internal connections for IMs */
1175
1176typedef void (*_XInternalConnectionProc)(
1177 Display* /* dpy */,
1178 int /* fd */,
1179 XPointer /* call_data */
1180);
1181
1182
1183extern Status _XRegisterInternalConnection(
1184 Display* /* dpy */,
1185 int /* fd */,
1186 _XInternalConnectionProc /* callback */,
1187 XPointer /* call_data */
1188);
1189
1190extern void _XUnregisterInternalConnection(
1191 Display* /* dpy */,
1192 int /* fd */
1193);
1194
1195extern void _XProcessInternalConnection(
1196 Display* /* dpy */,
1197 struct _XConnectionInfo* /* conn_info */
1198);
1199
1200/* Display structure has pointers to these */
1201
1202struct _XConnectionInfo { /* info from _XRegisterInternalConnection */
1203 int fd;
1204 _XInternalConnectionProc read_callback;
1205 XPointer call_data;
1206 XPointer *watch_data; /* set/used by XConnectionWatchProc */
1207 struct _XConnectionInfo *next;
1208};
1209
1210struct _XConnWatchInfo { /* info from XAddConnectionWatch */
1211 XConnectionWatchProc fn;
1212 XPointer client_data;
1213 struct _XConnWatchInfo *next;
1214};
1215
1216#ifdef __UNIXOS2__
1217extern char* __XOS2RedirRoot(
1218 char*
1219);
1220#endif
1221
1222extern int _XTextHeight(
1223 XFontStruct* /* font_struct */,
1224 _Xconst char* /* string */,
1225 int /* count */
1226);
1227
1228extern int _XTextHeight16(
1229 XFontStruct* /* font_struct */,
1230 _Xconst XChar2b* /* string */,
1231 int /* count */
1232);
1233
1234#if defined(WIN32)
1235
1236extern int _XOpenFile(
1237 _Xconst char* /* path */,
1238 int /* flags */
1239);
1240
1241extern int _XOpenFileMode(
1242 _Xconst char* /* path */,
1243 int /* flags */,
1244 mode_t /* mode */
1245);
1246
1247extern void* _XFopenFile(
1248 _Xconst char* /* path */,
1249 _Xconst char* /* mode */
1250);
1251
1252extern int _XAccessFile(
1253 _Xconst char* /* path */
1254);
1255#else
1256#define _XOpenFile(path,flags) open(path,flags)
1257#define _XOpenFileMode(path,flags,mode) open(path,flags,mode)
1258#define _XFopenFile(path,mode) fopen(path,mode)
1259#endif
1260
1261/* EvToWire.c */
1262extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event);
1263
1264extern int _XF86LoadQueryLocaleFont(
1265 Display* /* dpy */,
1266 _Xconst char* /* name*/,
1267 XFontStruct** /* xfp*/,
1268 Font* /* fidp */
1269);
1270
1271extern void _XProcessWindowAttributes (
1272 register Display *dpy,
1273 xChangeWindowAttributesReq *req,
1274 register unsigned long valuemask,
1275 register XSetWindowAttributes *attributes);
1276
1277extern int _XDefaultError(
1278 Display *dpy,
1279 XErrorEvent *event);
1280
1281extern int _XDefaultIOError(
1282 Display *dpy);
1283
1284extern void _XSetClipRectangles (
1285 register Display *dpy,
1286 GC gc,
1287 int clip_x_origin, int clip_y_origin,
1288 XRectangle *rectangles,
1289 int n,
1290 int ordering);
1291
1292Status _XGetWindowAttributes(
1293 register Display *dpy,
1294 Window w,
1295 XWindowAttributes *attr);
1296
1297int _XPutBackEvent (
1298 register Display *dpy,
1299 register XEvent *event);
1300
1301extern Bool _XIsEventCookie(
1302 Display *dpy,
1303 XEvent *ev);
1304
1305extern void _XFreeEventCookies(
1306 Display *dpy);
1307
1308extern void _XStoreEventCookie(
1309 Display *dpy,
1310 XEvent *ev);
1311
1312extern Bool _XFetchEventCookie(
1313 Display *dpy,
1314 XGenericEventCookie *ev);
1315
1316extern Bool _XCopyEventCookie(
1317 Display *dpy,
1318 XGenericEventCookie *in,
1319 XGenericEventCookie *out);
1320
1321/* lcFile.c */
1322
1323extern void xlocaledir(
1324 char *buf,
1325 int buf_len
1326);
1327
1328#ifdef __clang__
1329#pragma clang diagnostic pop
1330#endif
1331
1332_XFUNCPROTOEND
1333
1334#endif /* _X11_XLIBINT_H_ */
1335

Warning: That file was not part of the compilation database. It may have many parsing errors.