1 /* $Xorg: Xlibint.h,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */
5 Copyright 1984, 1985, 1987, 1989, 1998 The Open Group
7 Permission to use, copy, modify, distribute, and sell this software and its
8 documentation for any purpose is hereby granted without fee, provided that
9 the above copyright notice appear in all copies and that both that
10 copyright notice and this permission notice appear in supporting
13 The above copyright notice and this permission notice shall be included
14 in all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of The Open Group shall
25 not be used in advertising or otherwise to promote the sale, use or
26 other dealings in this Software without prior written authorization
30 /* $XFree86: xc/lib/X11/Xlibint.h,v 3.27 2003/05/27 22:26:26 tsi Exp $ */
36 * Xlibint.h - Header definition and support file for the internal
37 * support routines used by the C subroutine interface
38 * library (Xlib) to the X Window System.
40 * Warning, there be dragons here....
44 #include <X11/Xproto.h> /* to declare xEvent */
45 #include <X11/XlibConf.h> /* for configured options like XTHREADS */
48 #define _XFlush _XFlushIt
52 * If your BytesReadable correctly detects broken connections, then
53 * you should NOT define XCONN_CHECK_FREQ.
55 #ifndef XCONN_CHECK_FREQ
56 #define XCONN_CHECK_FREQ 256
61 XExtData *ext_data; /* hook for extension to hang data */
62 GContext gid; /* protocol ID for graphics context */
63 Bool rects; /* boolean: TRUE if clipmask is list of rectangles */
64 Bool dashes; /* boolean: TRUE if dash-list is really a list */
65 unsigned long dirty;/* cache dirty bits */
66 XGCValues values; /* shadow structure of values */
71 XExtData *ext_data; /* hook for extension to hang data */
72 struct _XFreeFuncs *free_funcs; /* internal free functions */
73 int fd; /* Network socket. */
74 int conn_checker; /* ugly thing used by _XEventsQueued */
75 int proto_major_version;/* maj. version of server's X protocol */
76 int proto_minor_version;/* minor version of server's X protocol */
77 char *vendor; /* vendor of the server hardware */
78 XID resource_base; /* resource ID base */
79 XID resource_mask; /* resource ID mask bits */
80 XID resource_id; /* allocator current ID */
81 int resource_shift; /* allocator shift to correct bits */
82 XID (*resource_alloc)( /* allocator function */
85 int byte_order; /* screen byte order, LSBFirst, MSBFirst */
86 int bitmap_unit; /* padding and data requirements */
87 int bitmap_pad; /* padding requirements on bitmaps */
88 int bitmap_bit_order; /* LeastSignificant or MostSignificant */
89 int nformats; /* number of pixmap formats in list */
90 ScreenFormat *pixmap_format; /* pixmap format list */
91 int vnumber; /* Xlib's X protocol version number. */
92 int release; /* release of the server */
93 struct _XSQEvent *head, *tail; /* Input event queue. */
94 int qlen; /* Length of input event queue */
95 unsigned long last_request_read; /* seq number of last event read */
96 unsigned long request; /* sequence number of last request. */
97 char *last_req; /* beginning of last request, or dummy */
98 char *buffer; /* Output buffer starting address. */
99 char *bufptr; /* Output buffer index pointer. */
100 char *bufmax; /* Output buffer maximum+1 address. */
101 unsigned max_request_size; /* maximum number 32 bit words in request*/
102 struct _XrmHashBucketRec *db;
103 int (*synchandler)( /* Synchronization handler */
106 char *display_name; /* "host:display" string used on this connect*/
107 int default_screen; /* default screen for operations */
108 int nscreens; /* number of screens on this server*/
109 Screen *screens; /* pointer to list of screens */
110 unsigned long motion_buffer; /* size of motion buffer */
111 unsigned long flags; /* internal connection flags */
112 int min_keycode; /* minimum defined keycode */
113 int max_keycode; /* maximum defined keycode */
114 KeySym *keysyms; /* This server's keysyms */
115 XModifierKeymap *modifiermap; /* This server's modifier keymap */
116 int keysyms_per_keycode;/* number of rows */
117 char *xdefaults; /* contents of defaults from server */
118 char *scratch_buffer; /* place to hang scratch buffer */
119 unsigned long scratch_length; /* length of scratch buffer */
120 int ext_number; /* extension number on this display */
121 struct _XExten *ext_procs; /* extensions initialized on this display */
123 * the following can be fixed size, as the protocol defines how
124 * much address space is available.
125 * While this could be done using the extension vector, there
126 * may be MANY events processed, so a search through the extension
127 * list to find the right procedure for each event might be
128 * expensive if many extensions are being used.
130 Bool (*event_vec[128])( /* vector for wire to event */
135 Status (*wire_vec[128])( /* vector for event to wire */
140 KeySym lock_meaning; /* for XLookupString */
141 struct _XLockInfo *lock; /* multi-thread state, display lock */
142 struct _XInternalAsync *async_handlers; /* for internal async */
143 unsigned long bigreq_size; /* max size of big requests */
144 struct _XLockPtrs *lock_fns; /* pointers to threads functions */
145 void (*idlist_alloc)( /* XID list allocator function */
150 /* things above this line should not move, for binary compatibility */
151 struct _XKeytrans *key_bindings; /* for XLookupString */
152 Font cursor_font; /* for XCreateFontCursor */
153 struct _XDisplayAtoms *atoms; /* for XInternAtom */
154 unsigned int mode_switch; /* keyboard group modifiers */
155 unsigned int num_lock; /* keyboard numlock modifiers */
156 struct _XContextDB *context_db; /* context database */
157 Bool (**error_vec)( /* vector for wire to error */
158 Display * /* display */,
159 XErrorEvent * /* he */,
166 XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */
167 XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */
168 XPointer perVisualIntensityMaps;
169 /* linked list of XcmsIntensityMap */
171 struct _XIMFilter *im_filters;
172 struct _XSQEvent *qfree; /* unallocated event queue elements */
173 unsigned long next_event_serial_num; /* inserted into next queue elt */
174 struct _XExten *flushes; /* Flush hooks */
175 struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */
176 int im_fd_length; /* number of im_fd_info */
177 struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */
178 int watcher_count; /* number of conn_watchers */
179 XPointer filedes; /* struct pollfd cache for _XWaitForReadable */
180 int (*savedsynchandler)( /* user synchandler when Xlib usurps */
183 XID resource_max; /* allocator max ID */
184 int xcmisc_opcode; /* major opcode for XC-MISC */
185 struct _XkbInfoRec *xkb_info; /* XKB info */
186 struct _XtransConnInfo *trans_conn; /* transport connection object */
189 #define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
192 * define the following if you want the Data macro to be a procedure instead
195 #define DataRoutineIsProcedure
200 * _QEvent datatype for use in input queueing.
202 typedef struct _XSQEvent
204 struct _XSQEvent *next;
206 unsigned long qserial_num; /* so multi-threaded code can find new ones */
210 #ifdef XTHREADS /* for xReply */
216 #include <X11/Xproto.h>
218 #define _SGI_MP_SOURCE /* turn this on to get MP safe errno */
221 #define _XBCOPYFUNC _Xbcopy
222 #include <X11/Xfuncs.h>
223 #include <X11/Xosdefs.h>
225 /* Utek leaves kernel macros around in include files (bleah) */
233 #include <X11/Xfuncproto.h>
238 * The following definitions can be used for locking requests in multi-threaded
242 /* Author: Stephen Gildea, MIT X Consortium
244 * declarations for C Threads locking
247 typedef struct _LockInfoRec *LockInfoPtr;
249 /* interfaces for locking.c */
251 /* used by all, including extensions; do not move */
252 void (*lock_display)(
254 #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
259 void (*unlock_display)(
261 #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
268 #if defined(WIN32) && !defined(_XLIBINT_)
269 #define _XCreateMutex_fn (*_XCreateMutex_fn_p)
270 #define _XFreeMutex_fn (*_XFreeMutex_fn_p)
271 #define _XLockMutex_fn (*_XLockMutex_fn_p)
272 #define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)
273 #define _Xglobal_lock (*_Xglobal_lock_p)
277 extern void (*_XCreateMutex_fn)(
278 LockInfoPtr /* lock */
280 extern void (*_XFreeMutex_fn)(
281 LockInfoPtr /* lock */
283 extern void (*_XLockMutex_fn)(
284 LockInfoPtr /* lock */
285 #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
290 extern void (*_XUnlockMutex_fn)(
291 LockInfoPtr /* lock */
292 #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
298 extern LockInfoPtr _Xglobal_lock;
300 #if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
301 #define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)
302 #define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)
303 #define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)
304 #define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)
306 /* used everywhere, so must be fast if not using threads */
307 #define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)
308 #define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)
309 #define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)
310 #define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)
312 #define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);
313 #define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);
316 #define LockDisplay(dis)
317 #define _XLockMutex(lock)
318 #define _XUnlockMutex(lock)
319 #define UnlockDisplay(dis)
320 #define _XCreateMutex(lock)
321 #define _XFreeMutex(lock)
324 #define Xfree(ptr) free((ptr))
327 * Note that some machines do not return a valid pointer for malloc(0), in
328 * which case we provide an alternate under the control of the
329 * define MALLOC_0_RETURNS_NULL. This is necessary because some
330 * Xlib code expects malloc(0) to return a valid pointer to storage.
332 #ifdef MALLOC_0_RETURNS_NULL
334 # define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
335 # define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
336 # define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))
340 # define Xmalloc(size) malloc((size))
341 # define Xrealloc(ptr, size) realloc((ptr), (size))
342 # define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
352 #define BUFSIZE 2048 /* X output buffer size. */
355 #define PTSPERBATCH 1024 /* point batching */
358 #define WLNSPERBATCH 50 /* wide line batching */
361 #define ZLNSPERBATCH 1024 /* thin line batching */
363 #ifndef WRCTSPERBATCH
364 #define WRCTSPERBATCH 10 /* wide line rectangle batching */
366 #ifndef ZRCTSPERBATCH
367 #define ZRCTSPERBATCH 256 /* thin line rectangle batching */
369 #ifndef FRCTSPERBATCH
370 #define FRCTSPERBATCH 256 /* filled rectangle batching */
372 #ifndef FARCSPERBATCH
373 #define FARCSPERBATCH 256 /* filled arc batching */
376 #define CURSORFONT "cursor" /* standard cursor fonts */
382 #define XlibDisplayIOError (1L << 0)
383 #define XlibDisplayClosing (1L << 1)
384 #define XlibDisplayNoXkb (1L << 2)
385 #define XlibDisplayPrivSync (1L << 3)
386 #define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */
387 #define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */
388 #define XlibDisplayReply (1L << 5) /* in _XReply */
389 #define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */
390 #define XlibDisplayDfltRMDB (1L << 7) /* mark if RM db from XGetDefault */
393 * X Protocol packetizing macros.
396 /* Need to start requests on 64 bit word boundaries
397 * on a CRAY computer so add a NoOp (127) if needed.
398 * A character pointer on a CRAY computer will be non-zero
399 * after shifting right 61 bits of it is not pointing to
403 #define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\
404 dpy->last_req = dpy->bufptr;\
405 *(dpy->bufptr) = X_NoOperation;\
406 *(dpy->bufptr+1) = 0;\
407 *(dpy->bufptr+2) = 0;\
408 *(dpy->bufptr+3) = 1;\
412 #else /* else does not require alignment on 64-bit boundaries */
418 * GetReq - Get the next available X request packet in the buffer and
421 * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
422 * "req" is the name of the request pointer.
426 #if !defined(UNIXCPP) || defined(ANSICPP)
427 #define GetReq(name, req) \
429 if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
431 req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
432 req->reqType = X_##name;\
433 req->length = (SIZEOF(x##name##Req))>>2;\
434 dpy->bufptr += SIZEOF(x##name##Req);\
437 #else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
438 #define GetReq(name, req) \
440 if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
442 req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
443 req->reqType = X_/**/name;\
444 req->length = (SIZEOF(x/**/name/**/Req))>>2;\
445 dpy->bufptr += SIZEOF(x/**/name/**/Req);\
449 /* GetReqExtra is the same as GetReq, but allocates "n" additional
450 bytes after the request. "n" must be a multiple of 4! */
452 #if !defined(UNIXCPP) || defined(ANSICPP)
453 #define GetReqExtra(name, n, req) \
455 if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\
457 req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
458 req->reqType = X_##name;\
459 req->length = (SIZEOF(x##name##Req) + n)>>2;\
460 dpy->bufptr += SIZEOF(x##name##Req) + n;\
463 #define GetReqExtra(name, n, req) \
465 if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\
467 req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
468 req->reqType = X_/**/name;\
469 req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\
470 dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\
476 * GetResReq is for those requests that have a resource ID
477 * (Window, Pixmap, GContext, etc.) as their single argument.
478 * "rid" is the name of the resource.
481 #if !defined(UNIXCPP) || defined(ANSICPP)
482 #define GetResReq(name, rid, req) \
484 if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
486 req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
487 req->reqType = X_##name;\
490 dpy->bufptr += SIZEOF(xResourceReq);\
493 #define GetResReq(name, rid, req) \
495 if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
497 req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
498 req->reqType = X_/**/name;\
501 dpy->bufptr += SIZEOF(xResourceReq);\
506 * GetEmptyReq is for those requests that have no arguments
509 #if !defined(UNIXCPP) || defined(ANSICPP)
510 #define GetEmptyReq(name, req) \
512 if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
514 req = (xReq *) (dpy->last_req = dpy->bufptr);\
515 req->reqType = X_##name;\
517 dpy->bufptr += SIZEOF(xReq);\
520 #define GetEmptyReq(name, req) \
522 if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
524 req = (xReq *) (dpy->last_req = dpy->bufptr);\
525 req->reqType = X_/**/name;\
527 dpy->bufptr += SIZEOF(xReq);\
532 #define MakeBigReq(req,n) \
535 unsigned long _BRlen = req->length - 1; \
537 memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \
538 memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
539 memcpy(((char *)req) + 4, _BRdat, 4); \
540 Data32(dpy, (long *)&_BRdat, 4); \
544 #define MakeBigReq(req,n) \
547 CARD32 _BRlen = req->length - 1; \
549 _BRdat = ((CARD32 *)req)[_BRlen]; \
550 memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
551 ((CARD32 *)req)[1] = _BRlen + n + 2; \
552 Data32(dpy, &_BRdat, 4); \
555 #define MakeBigReq(req,n) \
558 CARD32 _BRlen = req->length - 1; \
560 _BRdat = ((CARD32 *)req)[_BRlen]; \
561 memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
562 ((CARD32 *)req)[1] = _BRlen + n + 2; \
563 Data32(dpy, &_BRdat, 4); \
568 #define SetReqLen(req,n,badlen) \
569 if ((req->length + n) > (unsigned)65535) { \
570 if (dpy->bigreq_size) { \
579 #define SyncHandle() \
580 if (dpy->synchandler) (*dpy->synchandler)(dpy)
582 extern void _XFlushGCCache(Display *dpy, GC gc);
583 #define FlushGC(dpy, gc) \
584 if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
586 * Data - Place data in the buffer and pad the end to provide
587 * 32 bit word alignment. Transmit if the buffer fills.
589 * "dpy" is a pointer to a Display.
590 * "data" is a pinter to a data buffer.
591 * "len" is the length of the data buffer.
593 #ifndef DataRoutineIsProcedure
594 #define Data(dpy, data, len) {\
595 if (dpy->bufptr + (len) <= dpy->bufmax) {\
596 memcpy(dpy->bufptr, data, (int)len);\
597 dpy->bufptr += ((len) + 3) & ~3;\
599 _XSend(dpy, data, len);\
601 #endif /* DataRoutineIsProcedure */
604 /* Allocate bytes from the buffer. No padding is done, so if
605 * the length is not a multiple of 4, the caller must be
606 * careful to leave the buffer aligned after sending the
609 * "type" is the type of the pointer being assigned to.
610 * "ptr" is the pointer being assigned to.
611 * "n" is the number of bytes to allocate.
615 * BufAlloc (xTextElt *, elt, nbytes)
618 #define BufAlloc(type, ptr, n) \
619 if (dpy->bufptr + (n) > dpy->bufmax) \
621 ptr = (type) dpy->bufptr; \
626 #define Data16(dpy, data, len) _XData16(dpy, (short *)data, len)
627 #define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
629 #define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
630 #define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
631 #define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
633 #define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
639 extern void _XRead32(
645 #define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
646 #define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
648 #endif /* not WORD64 */
650 #define PackData16(dpy,data,len) Data16 (dpy, data, len)
651 #define PackData32(dpy,data,len) Data32 (dpy, data, len)
653 /* Xlib manual is bogus */
654 #define PackData(dpy,data,len) PackData16 (dpy, data, len)
656 #define min(a,b) (((a) < (b)) ? (a) : (b))
657 #define max(a,b) (((a) > (b)) ? (a) : (b))
659 #define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
660 (((cs)->rbearing|(cs)->lbearing| \
661 (cs)->ascent|(cs)->descent) == 0))
664 * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit
665 * character. If the character is in the column and exists, then return the
666 * appropriate metrics (note that fonts with common per-character metrics will
667 * return min_bounds). If none of these hold true, try again with the default
670 #define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
673 if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
674 if (fs->per_char == NULL) { \
675 cs = &fs->min_bounds; \
677 cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
678 if (CI_NONEXISTCHAR(cs)) cs = def; \
683 #define CI_GET_DEFAULT_INFO_1D(fs,cs) \
684 CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
689 * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and
690 * column. This is used for fonts that have more than row zero.
692 #define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
695 if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
696 col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
697 if (fs->per_char == NULL) { \
698 cs = &fs->min_bounds; \
700 cs = &fs->per_char[((row - fs->min_byte1) * \
701 (fs->max_char_or_byte2 - \
702 fs->min_char_or_byte2 + 1)) + \
703 (col - fs->min_char_or_byte2)]; \
704 if (CI_NONEXISTCHAR(cs)) cs = def; \
709 #define CI_GET_DEFAULT_INFO_2D(fs,cs) \
711 unsigned int r = (fs->default_char >> 8); \
712 unsigned int c = (fs->default_char & 0xff); \
713 CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
719 /* for when 32-bit alignment is not good enough */
720 #define OneDataCard32(dpy,dstaddr,srcvar) \
721 { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); }
725 /* srcvar must be a variable for large architecture version */
726 #define OneDataCard32(dpy,dstaddr,srcvar) \
727 { *(CARD32 *)(dstaddr) = (srcvar); }
729 #endif /* MUSTCOPY */
731 typedef struct _XInternalAsync {
732 struct _XInternalAsync *next;
735 * rep is the generic reply that caused this handler
736 * to be invoked. It must also be passed to _XGetAsyncReply.
737 * buf and len are opaque values that must be passed to
738 * _XGetAsyncReply or _XGetAsyncData.
739 * data is the closure stored in this struct.
740 * The handler returns True iff it handled this reply.
752 typedef struct _XAsyncEState {
753 unsigned long min_sequence_number;
754 unsigned long max_sequence_number;
755 unsigned char error_code;
756 unsigned char major_opcode;
757 unsigned short minor_opcode;
758 unsigned char last_error_received;
762 extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler);
763 #define DeqAsyncHandler(dpy,handler) { \
764 if (dpy->async_handlers == (handler)) \
765 dpy->async_handlers = (handler)->next; \
767 _XDeqAsyncHandler(dpy, handler); \
770 typedef void (*FreeFuncType) (
771 Display* /* display */
774 typedef int (*FreeModmapType) (
775 XModifierKeymap* /* modmap */
779 * This structure is private to the library.
781 typedef struct _XFreeFuncs {
782 FreeFuncType atoms; /* _XFreeAtomTable */
783 FreeModmapType modifiermap; /* XFreeModifierMap */
784 FreeFuncType key_bindings; /* _XFreeKeyBindings */
785 FreeFuncType context_db; /* _XFreeContextDB */
786 FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */
787 FreeFuncType clientCmaps; /* _XcmsFreeClientCmaps */
788 FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */
789 FreeFuncType im_filters; /* _XFreeIMFilters */
790 FreeFuncType xkb; /* _XkbFreeInfo */
793 /* types for InitExt.c */
794 typedef int (*CreateGCType) (
795 Display* /* display */,
797 XExtCodes* /* codes */
800 typedef int (*CopyGCType)(
801 Display* /* display */,
803 XExtCodes* /* codes */
806 typedef int (*FlushGCType) (
807 Display* /* display */,
809 XExtCodes* /* codes */
812 typedef int (*FreeGCType) (
813 Display* /* display */,
815 XExtCodes* /* codes */
818 typedef int (*CreateFontType) (
819 Display* /* display */,
820 XFontStruct* /* fs */,
821 XExtCodes* /* codes */
824 typedef int (*FreeFontType) (
825 Display* /* display */,
826 XFontStruct* /* fs */,
827 XExtCodes* /* codes */
830 typedef int (*CloseDisplayType) (
831 Display* /* display */,
832 XExtCodes* /* codes */
835 typedef int (*ErrorType) (
836 Display* /* display */,
838 XExtCodes* /* codes */,
842 typedef char* (*ErrorStringType) (
843 Display* /* display */,
845 XExtCodes* /* codes */,
850 typedef void (*PrintErrorType)(
851 Display* /* display */,
852 XErrorEvent* /* ev */,
856 typedef void (*BeforeFlushType)(
857 Display* /* display */,
858 XExtCodes* /* codes */,
859 _Xconst char* /* data */,
864 * This structure is private to the library.
866 typedef struct _XExten { /* private to extension mechanism */
867 struct _XExten *next; /* next in list */
868 XExtCodes codes; /* public information, all extension told */
869 CreateGCType create_GC; /* routine to call when GC created */
870 CopyGCType copy_GC; /* routine to call when GC copied */
871 FlushGCType flush_GC; /* routine to call when GC flushed */
872 FreeGCType free_GC; /* routine to call when GC freed */
873 CreateFontType create_Font; /* routine to call when Font created */
874 FreeFontType free_Font; /* routine to call when Font freed */
875 CloseDisplayType close_display; /* routine to call when connection closed */
876 ErrorType error; /* who to call when an error occurs */
877 ErrorStringType error_string; /* routine to supply error string */
878 char *name; /* name of this extension */
879 PrintErrorType error_values; /* routine to supply error values */
880 BeforeFlushType before_flush; /* routine to call when sending data */
881 struct _XExten *next_flush; /* next in list of those with flushes */
884 /* extension hooks */
886 #ifdef DataRoutineIsProcedure
887 extern void Data(Display *dpy, char *data, long len);
893 extern int _XIOError(
896 extern int (*_XIOErrorFunction)(
899 extern int (*_XErrorFunction)(
901 XErrorEvent* /* error_event */
903 extern void _XEatData(
905 unsigned long /* n */
907 extern char *_XAllocScratch(
909 unsigned long /* nbytes */
911 extern char *_XAllocTemp(
913 unsigned long /* nbytes */
915 extern void _XFreeTemp(
918 unsigned long /* nbytes */
920 extern Visual *_XVIDtoVisual(
924 extern unsigned long _XSetLastRequestRead(
926 xGenericReply* /* rep */
928 extern int _XGetHostname(
932 extern Screen *_XScreenOfWindow(
936 extern Bool _XAsyncErrorHandler(
943 extern char *_XGetAsyncReply(
952 extern void _XGetAsyncData(
959 int /* discardtotal */
964 extern int _XEventsQueued(
968 extern void _XReadEvents(
976 extern void _XReadPad(
983 _Xconst char* /* data */,
986 extern Status _XReply(
998 _XQEvent* /* prev */,
1002 extern Bool _XUnknownWireEvent(
1007 extern Status _XUnknownNativeEvent(
1013 extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event);
1014 extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we);
1015 extern Bool _XPollfdCacheInit(Display *dpy);
1016 extern void _XPollfdCacheAdd(Display *dpy, int fd);
1017 extern void _XPollfdCacheDel(Display *dpy, int fd);
1018 extern XID _XAllocID(Display *dpy);
1019 extern void _XAllocIDs(Display *dpy, XID *ids, int count);
1021 extern int _XFreeExtData(
1022 XExtData* /* extension */
1025 extern int (*XESetCreateGC(
1026 Display* /* display */,
1027 int /* extension */,
1029 Display* /* display */,
1031 XExtCodes* /* codes */
1034 Display*, GC, XExtCodes*
1037 extern int (*XESetCopyGC(
1038 Display* /* display */,
1039 int /* extension */,
1041 Display* /* display */,
1043 XExtCodes* /* codes */
1046 Display*, GC, XExtCodes*
1049 extern int (*XESetFlushGC(
1050 Display* /* display */,
1051 int /* extension */,
1053 Display* /* display */,
1055 XExtCodes* /* codes */
1058 Display*, GC, XExtCodes*
1061 extern int (*XESetFreeGC(
1062 Display* /* display */,
1063 int /* extension */,
1065 Display* /* display */,
1067 XExtCodes* /* codes */
1070 Display*, GC, XExtCodes*
1073 extern int (*XESetCreateFont(
1074 Display* /* display */,
1075 int /* extension */,
1077 Display* /* display */,
1078 XFontStruct* /* fs */,
1079 XExtCodes* /* codes */
1082 Display*, XFontStruct*, XExtCodes*
1085 extern int (*XESetFreeFont(
1086 Display* /* display */,
1087 int /* extension */,
1089 Display* /* display */,
1090 XFontStruct* /* fs */,
1091 XExtCodes* /* codes */
1094 Display*, XFontStruct*, XExtCodes*
1097 extern int (*XESetCloseDisplay(
1098 Display* /* display */,
1099 int /* extension */,
1101 Display* /* display */,
1102 XExtCodes* /* codes */
1105 Display*, XExtCodes*
1108 extern int (*XESetError(
1109 Display* /* display */,
1110 int /* extension */,
1112 Display* /* display */,
1114 XExtCodes* /* codes */,
1118 Display*, xError*, XExtCodes*, int*
1121 extern char* (*XESetErrorString(
1122 Display* /* display */,
1123 int /* extension */,
1125 Display* /* display */,
1127 XExtCodes* /* codes */,
1132 Display*, int, XExtCodes*, char*, int
1135 extern void (*XESetPrintErrorValues (
1136 Display* /* display */,
1137 int /* extension */,
1139 Display* /* display */,
1140 XErrorEvent* /* ev */,
1144 Display*, XErrorEvent*, void*
1147 extern Bool (*XESetWireToEvent(
1148 Display* /* display */,
1149 int /* event_number */,
1151 Display* /* display */,
1156 Display*, XEvent*, xEvent*
1159 extern Status (*XESetEventToWire(
1160 Display* /* display */,
1161 int /* event_number */,
1163 Display* /* display */,
1168 Display*, XEvent*, xEvent*
1171 extern Bool (*XESetWireToError(
1172 Display* /* display */,
1173 int /* error_number */,
1175 Display* /* display */,
1176 XErrorEvent* /* he */,
1180 Display*, XErrorEvent*, xError*
1183 extern void (*XESetBeforeFlush(
1184 Display* /* display */,
1185 int /* error_number */,
1187 Display* /* display */,
1188 XExtCodes* /* codes */,
1189 _Xconst char* /* data */,
1193 Display*, XExtCodes*, _Xconst char*, long
1196 /* internal connections for IMs */
1198 typedef void (*_XInternalConnectionProc)(
1201 XPointer /* call_data */
1205 extern Status _XRegisterInternalConnection(
1208 _XInternalConnectionProc /* callback */,
1209 XPointer /* call_data */
1212 extern void _XUnregisterInternalConnection(
1217 /* Display structure has pointers to these */
1219 struct _XConnectionInfo { /* info from _XRegisterInternalConnection */
1221 _XInternalConnectionProc read_callback;
1223 XPointer *watch_data; /* set/used by XConnectionWatchProc */
1224 struct _XConnectionInfo *next;
1227 struct _XConnWatchInfo { /* info from XAddConnectionWatch */
1228 XConnectionWatchProc fn;
1229 XPointer client_data;
1230 struct _XConnWatchInfo *next;
1234 extern char* __XOS2RedirRoot(
1239 extern int _XTextHeight(
1240 XFontStruct* /* font_struct */,
1241 _Xconst char* /* string */,
1245 extern int _XTextHeight16(
1246 XFontStruct* /* font_struct */,
1247 _Xconst XChar2b* /* string */,
1253 extern int _XOpenFile(
1254 _Xconst char* /* path */,
1258 extern int _XOpenFileMode(
1259 _Xconst char* /* path */,
1264 extern void* _XFopenFile(
1265 _Xconst char* /* path */,
1266 _Xconst char* /* mode */
1269 extern int _XAccessFile(
1270 _Xconst char* /* path */
1273 #define _XOpenFile(path,flags) open(path,flags)
1274 #define _XOpenFileMode(path,flags,mode) open(path,flags,mode)
1275 #define _XFopenFile(path,mode) fopen(path,mode)
1279 extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event);
1281 extern int _XF86LoadQueryLocaleFont(
1283 _Xconst char* /* name*/,
1284 XFontStruct** /* xfp*/,
1288 extern void _XProcessWindowAttributes (
1289 register Display *dpy,
1290 xChangeWindowAttributesReq *req,
1291 register unsigned long valuemask,
1292 register XSetWindowAttributes *attributes);
1294 extern int _XDefaultError(
1296 XErrorEvent *event);
1298 extern int _XDefaultIOError(
1301 extern void _XSetClipRectangles (
1302 register Display *dpy,
1304 int clip_x_origin, int clip_y_origin,
1305 XRectangle *rectangles,
1309 Status _XGetWindowAttributes(
1310 register Display *dpy,
1312 XWindowAttributes *attr);
1314 int _XPutBackEvent (
1315 register Display *dpy,
1316 register XEvent *event);
1320 #endif /* _XLIBINT_H_ */