Debian Codegraph @

nx-X11/lib/include/X11/Xlibint.h

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