Path: blob/main/system/include/X11/Xlibint.h
6162 views
1/*23Copyright 1984, 1985, 1987, 1989, 1998 The Open Group45Permission to use, copy, modify, distribute, and sell this software and its6documentation for any purpose is hereby granted without fee, provided that7the above copyright notice appear in all copies and that both that8copyright notice and this permission notice appear in supporting9documentation.1011The above copyright notice and this permission notice shall be included12in all copies or substantial portions of the Software.1314THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR20OTHER DEALINGS IN THE SOFTWARE.2122Except as contained in this notice, the name of The Open Group shall23not be used in advertising or otherwise to promote the sale, use or24other dealings in this Software without prior written authorization25from The Open Group.2627*/2829#ifndef _X11_XLIBINT_H_30#define _X11_XLIBINT_H_ 13132/*33* Xlibint.h - Header definition and support file for the internal34* support routines used by the C subroutine interface35* library (Xlib) to the X Window System.36*37* Warning, there be dragons here....38*/3940#include <X11/Xlib.h>41#include <X11/Xproto.h> /* to declare xEvent */42#include <X11/XlibConf.h> /* for configured options like XTHREADS */4344#ifdef WIN3245#define _XFlush _XFlushIt46#endif4748/*49* If your BytesReadable correctly detects broken connections, then50* you should NOT define XCONN_CHECK_FREQ.51*/52#ifndef XCONN_CHECK_FREQ53#define XCONN_CHECK_FREQ 25654#endif5556struct _XGC57{58XExtData *ext_data; /* hook for extension to hang data */59GContext gid; /* protocol ID for graphics context */60Bool rects; /* boolean: TRUE if clipmask is list of rectangles */61Bool dashes; /* boolean: TRUE if dash-list is really a list */62unsigned long dirty;/* cache dirty bits */63XGCValues values; /* shadow structure of values */64};6566struct _XDisplay67{68XExtData *ext_data; /* hook for extension to hang data */69struct _XFreeFuncs *free_funcs; /* internal free functions */70int fd; /* Network socket. */71int conn_checker; /* ugly thing used by _XEventsQueued */72int proto_major_version;/* maj. version of server's X protocol */73int proto_minor_version;/* minor version of server's X protocol */74char *vendor; /* vendor of the server hardware */75XID resource_base; /* resource ID base */76XID resource_mask; /* resource ID mask bits */77XID resource_id; /* allocator current ID */78int resource_shift; /* allocator shift to correct bits */79XID (*resource_alloc)( /* allocator function */80struct _XDisplay*81);82int byte_order; /* screen byte order, LSBFirst, MSBFirst */83int bitmap_unit; /* padding and data requirements */84int bitmap_pad; /* padding requirements on bitmaps */85int bitmap_bit_order; /* LeastSignificant or MostSignificant */86int nformats; /* number of pixmap formats in list */87ScreenFormat *pixmap_format; /* pixmap format list */88int vnumber; /* Xlib's X protocol version number. */89int release; /* release of the server */90struct _XSQEvent *head, *tail; /* Input event queue. */91int qlen; /* Length of input event queue */92unsigned long last_request_read; /* seq number of last event read */93unsigned long request; /* sequence number of last request. */94char *last_req; /* beginning of last request, or dummy */95char *buffer; /* Output buffer starting address. */96char *bufptr; /* Output buffer index pointer. */97char *bufmax; /* Output buffer maximum+1 address. */98unsigned max_request_size; /* maximum number 32 bit words in request*/99struct _XrmHashBucketRec *db;100int (*synchandler)( /* Synchronization handler */101struct _XDisplay*102);103char *display_name; /* "host:display" string used on this connect*/104int default_screen; /* default screen for operations */105int nscreens; /* number of screens on this server*/106Screen *screens; /* pointer to list of screens */107unsigned long motion_buffer; /* size of motion buffer */108volatile unsigned long flags; /* internal connection flags */109int min_keycode; /* minimum defined keycode */110int max_keycode; /* maximum defined keycode */111KeySym *keysyms; /* This server's keysyms */112XModifierKeymap *modifiermap; /* This server's modifier keymap */113int keysyms_per_keycode;/* number of rows */114char *xdefaults; /* contents of defaults from server */115char *scratch_buffer; /* place to hang scratch buffer */116unsigned long scratch_length; /* length of scratch buffer */117int ext_number; /* extension number on this display */118struct _XExten *ext_procs; /* extensions initialized on this display */119/*120* the following can be fixed size, as the protocol defines how121* much address space is available.122* While this could be done using the extension vector, there123* may be MANY events processed, so a search through the extension124* list to find the right procedure for each event might be125* expensive if many extensions are being used.126*/127Bool (*event_vec[128])( /* vector for wire to event */128Display * /* dpy */,129XEvent * /* re */,130xEvent * /* event */131);132Status (*wire_vec[128])( /* vector for event to wire */133Display * /* dpy */,134XEvent * /* re */,135xEvent * /* event */136);137KeySym lock_meaning; /* for XLookupString */138struct _XLockInfo *lock; /* multi-thread state, display lock */139struct _XInternalAsync *async_handlers; /* for internal async */140unsigned long bigreq_size; /* max size of big requests */141struct _XLockPtrs *lock_fns; /* pointers to threads functions */142void (*idlist_alloc)( /* XID list allocator function */143Display * /* dpy */,144XID * /* ids */,145int /* count */146);147/* things above this line should not move, for binary compatibility */148struct _XKeytrans *key_bindings; /* for XLookupString */149Font cursor_font; /* for XCreateFontCursor */150struct _XDisplayAtoms *atoms; /* for XInternAtom */151unsigned int mode_switch; /* keyboard group modifiers */152unsigned int num_lock; /* keyboard numlock modifiers */153struct _XContextDB *context_db; /* context database */154Bool (**error_vec)( /* vector for wire to error */155Display * /* display */,156XErrorEvent * /* he */,157xError * /* we */158);159/*160* Xcms information161*/162struct {163XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */164XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */165XPointer perVisualIntensityMaps;166/* linked list of XcmsIntensityMap */167} cms;168struct _XIMFilter *im_filters;169struct _XSQEvent *qfree; /* unallocated event queue elements */170unsigned long next_event_serial_num; /* inserted into next queue elt */171struct _XExten *flushes; /* Flush hooks */172struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */173int im_fd_length; /* number of im_fd_info */174struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */175int watcher_count; /* number of conn_watchers */176XPointer filedes; /* struct pollfd cache for _XWaitForReadable */177int (*savedsynchandler)( /* user synchandler when Xlib usurps */178Display * /* dpy */179);180XID resource_max; /* allocator max ID */181int xcmisc_opcode; /* major opcode for XC-MISC */182struct _XkbInfoRec *xkb_info; /* XKB info */183struct _XtransConnInfo *trans_conn; /* transport connection object */184struct _X11XCBPrivate *xcb; /* XCB glue private data */185186/* Generic event cookie handling */187unsigned int next_cookie; /* next event cookie */188/* vector for wire to generic event, index is (extension - 128) */189Bool (*generic_event_vec[128])(190Display * /* dpy */,191XGenericEventCookie * /* Xlib event */,192xEvent * /* wire event */);193/* vector for event copy, index is (extension - 128) */194Bool (*generic_event_copy_vec[128])(195Display * /* dpy */,196XGenericEventCookie * /* in */,197XGenericEventCookie * /* out*/);198void *cookiejar; /* cookie events returned but not claimed */199};200201#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)202203/*204* define the following if you want the Data macro to be a procedure instead205*/206#ifdef CRAY207#define DataRoutineIsProcedure208#endif /* CRAY */209210#ifndef _XEVENT_211/*212* _QEvent datatype for use in input queueing.213*/214typedef struct _XSQEvent215{216struct _XSQEvent *next;217XEvent event;218unsigned long qserial_num; /* so multi-threaded code can find new ones */219} _XQEvent;220#endif221222#include <X11/Xproto.h>223#ifdef __sgi224#define _SGI_MP_SOURCE /* turn this on to get MP safe errno */225#endif226#include <errno.h>227#define _XBCOPYFUNC _Xbcopy228#include <X11/Xfuncs.h>229#include <X11/Xosdefs.h>230231/* Utek leaves kernel macros around in include files (bleah) */232#ifdef dirty233#undef dirty234#endif235236#include <stdlib.h>237#include <string.h>238239#include <X11/Xfuncproto.h>240241_XFUNCPROTOBEGIN242243/*244* The following definitions can be used for locking requests in multi-threaded245* address spaces.246*/247#ifdef XTHREADS248/* Author: Stephen Gildea, MIT X Consortium249*250* declarations for C Threads locking251*/252253typedef struct _LockInfoRec *LockInfoPtr;254255/* interfaces for locking.c */256struct _XLockPtrs {257/* used by all, including extensions; do not move */258void (*lock_display)(259Display *dpy260#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)261, char *file262, int line263#endif264);265void (*unlock_display)(266Display *dpy267#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)268, char *file269, int line270#endif271);272};273274#if defined(WIN32) && !defined(_XLIBINT_)275#define _XCreateMutex_fn (*_XCreateMutex_fn_p)276#define _XFreeMutex_fn (*_XFreeMutex_fn_p)277#define _XLockMutex_fn (*_XLockMutex_fn_p)278#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)279#define _Xglobal_lock (*_Xglobal_lock_p)280#endif281282/* in XlibInt.c */283extern void (*_XCreateMutex_fn)(284LockInfoPtr /* lock */285);286extern void (*_XFreeMutex_fn)(287LockInfoPtr /* lock */288);289extern void (*_XLockMutex_fn)(290LockInfoPtr /* lock */291#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)292, char * /* file */293, int /* line */294#endif295);296extern void (*_XUnlockMutex_fn)(297LockInfoPtr /* lock */298#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)299, char * /* file */300, int /* line */301#endif302);303304extern LockInfoPtr _Xglobal_lock;305306#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)307#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)308#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)309#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)310#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)311#else312/* used everywhere, so must be fast if not using threads */313#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)314#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)315#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)316#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)317#endif318#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);319#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);320321#else /* XTHREADS */322#define LockDisplay(dis)323#define _XLockMutex(lock)324#define _XUnlockMutex(lock)325#define UnlockDisplay(dis)326#define _XCreateMutex(lock)327#define _XFreeMutex(lock)328#endif329330#define Xfree(ptr) free((ptr))331332/*333* Note that some machines do not return a valid pointer for malloc(0), in334* which case we provide an alternate under the control of the335* define MALLOC_0_RETURNS_NULL. This is necessary because some336* Xlib code expects malloc(0) to return a valid pointer to storage.337*/338#if defined(MALLOC_0_RETURNS_NULL) || defined(__clang_analyzer__)339340# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))341# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))342# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))343344#else345346# define Xmalloc(size) malloc((size))347# define Xrealloc(ptr, size) realloc((ptr), (size))348# define Xcalloc(nelem, elsize) calloc((nelem), (elsize))349350#endif351352#include <stddef.h>353354#define LOCKED 1355#define UNLOCKED 0356357#ifndef BUFSIZE358#define BUFSIZE 2048 /* X output buffer size. */359#endif360#ifndef PTSPERBATCH361#define PTSPERBATCH 1024 /* point batching */362#endif363#ifndef WLNSPERBATCH364#define WLNSPERBATCH 50 /* wide line batching */365#endif366#ifndef ZLNSPERBATCH367#define ZLNSPERBATCH 1024 /* thin line batching */368#endif369#ifndef WRCTSPERBATCH370#define WRCTSPERBATCH 10 /* wide line rectangle batching */371#endif372#ifndef ZRCTSPERBATCH373#define ZRCTSPERBATCH 256 /* thin line rectangle batching */374#endif375#ifndef FRCTSPERBATCH376#define FRCTSPERBATCH 256 /* filled rectangle batching */377#endif378#ifndef FARCSPERBATCH379#define FARCSPERBATCH 256 /* filled arc batching */380#endif381#ifndef CURSORFONT382#define CURSORFONT "cursor" /* standard cursor fonts */383#endif384385/*386* Display flags387*/388#define XlibDisplayIOError (1L << 0)389#define XlibDisplayClosing (1L << 1)390#define XlibDisplayNoXkb (1L << 2)391#define XlibDisplayPrivSync (1L << 3)392#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */393#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */394#define XlibDisplayReply (1L << 5) /* in _XReply */395#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */396#define XlibDisplayDfltRMDB (1L << 7) /* mark if RM db from XGetDefault */397398/*399* X Protocol packetizing macros.400*/401402/* Need to start requests on 64 bit word boundaries403* on a CRAY computer so add a NoOp (127) if needed.404* A character pointer on a CRAY computer will be non-zero405* after shifting right 61 bits of it is not pointing to406* a word boundary.407*/408#ifdef WORD64409#define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\410dpy->last_req = dpy->bufptr;\411*(dpy->bufptr) = X_NoOperation;\412*(dpy->bufptr+1) = 0;\413*(dpy->bufptr+2) = 0;\414*(dpy->bufptr+3) = 1;\415dpy->request++;\416dpy->bufptr += 4;\417}418#else /* else does not require alignment on 64-bit boundaries */419#define WORD64ALIGN420#endif /* WORD64 */421422/**423* Return a len-sized request buffer for the request type. This function may424* flush the output queue.425*426* @param dpy The display connection427* @param type The request type428* @param len Length of the request in bytes429*430* @returns A pointer to the request buffer with a few default values431* initialized.432*/433extern void *_XGetRequest(Display *dpy, CARD8 type, size_t len);434435/* GetReqSized is the same as GetReq but allows the caller to specify the436* size in bytes. 'sz' must be a multiple of 4! */437438#if !defined(UNIXCPP) || defined(ANSICPP)439#define GetReqSized(name, sz, req) \440req = (x##name##Req *) _XGetRequest(dpy, X_##name, sz)441#else442#define GetReqSized(name, sz, req) \443req = (x/**/name/**/Req *) _XGetRequest(dpy, X_/**/name, sz)444#endif445446447/*448* GetReq - Get the next available X request packet in the buffer and449* return it.450*451* "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.452* "req" is the name of the request pointer.453*454*/455456#if !defined(UNIXCPP) || defined(ANSICPP)457#define GetReq(name, req) \458GetReqSized(name, SIZEOF(x##name##Req), req)459#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */460#define GetReq(name, req) \461GetReqSized(name, SIZEOF(x/**/name/**/Req), req)462#endif463464/* GetReqExtra is the same as GetReq, but allocates "n" additional465bytes after the request. "n" must be a multiple of 4! */466467#if !defined(UNIXCPP) || defined(ANSICPP)468#define GetReqExtra(name, n, req) \469GetReqSized(name, SIZEOF(x##name##Req) + n, req)470#else471#define GetReqExtra(name, n, req) \472GetReqSized(name, SIZEOF(x/**/name/**/Req) + n, req)473#endif474475476/*477* GetResReq is for those requests that have a resource ID478* (Window, Pixmap, GContext, etc.) as their single argument.479* "rid" is the name of the resource.480*/481482#if !defined(UNIXCPP) || defined(ANSICPP)483#define GetResReq(name, rid, req) \484req = (xResourceReq *) _XGetRequest(dpy, X_##name, SIZEOF(xResourceReq)); \485req->id = (rid)486#else487#define GetResReq(name, rid, req) \488req = (xResourceReq *) _XGetRequest(dpy, X_/**/name, SIZEOF(xResourceReq)); \489req->id = (rid)490#endif491492/*493* GetEmptyReq is for those requests that have no arguments494* at all.495*/496#if !defined(UNIXCPP) || defined(ANSICPP)497#define GetEmptyReq(name, req) \498req = (xReq *) _XGetRequest(dpy, X_##name, SIZEOF(xReq))499#else500#define GetEmptyReq(name, req) \501req = (xReq *) _XGetRequest(dpy, X_/**/name, SIZEOF(xReq))502#endif503504#ifdef WORD64505#define MakeBigReq(req,n) \506{ \507char _BRdat[4]; \508unsigned long _BRlen = req->length - 1; \509req->length = 0; \510memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \511memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \512memcpy(((char *)req) + 4, _BRdat, 4); \513Data32(dpy, (long *)&_BRdat, 4); \514}515#else516#ifdef LONG64517#define MakeBigReq(req,n) \518{ \519CARD64 _BRdat; \520CARD32 _BRlen = req->length - 1; \521req->length = 0; \522_BRdat = ((CARD32 *)req)[_BRlen]; \523memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \524((CARD32 *)req)[1] = _BRlen + n + 2; \525Data32(dpy, &_BRdat, 4); \526}527#else528#define MakeBigReq(req,n) \529{ \530CARD32 _BRdat; \531CARD32 _BRlen = req->length - 1; \532req->length = 0; \533_BRdat = ((CARD32 *)req)[_BRlen]; \534memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \535((CARD32 *)req)[1] = _BRlen + n + 2; \536Data32(dpy, &_BRdat, 4); \537}538#endif539#endif540541#ifndef __clang_analyzer__542#define SetReqLen(req,n,badlen) \543if ((req->length + n) > (unsigned)65535) { \544if (dpy->bigreq_size) { \545MakeBigReq(req,n) \546} else { \547n = badlen; \548req->length += n; \549} \550} else \551req->length += n552#else553#define SetReqLen(req,n,badlen) \554req->length += n555#endif556557#define SyncHandle() \558if (dpy->synchandler) (*dpy->synchandler)(dpy)559560extern void _XFlushGCCache(Display *dpy, GC gc);561#define FlushGC(dpy, gc) \562if ((gc)->dirty) _XFlushGCCache((dpy), (gc))563/*564* Data - Place data in the buffer and pad the end to provide565* 32 bit word alignment. Transmit if the buffer fills.566*567* "dpy" is a pointer to a Display.568* "data" is a pinter to a data buffer.569* "len" is the length of the data buffer.570*/571#ifndef DataRoutineIsProcedure572#define Data(dpy, data, len) {\573if (dpy->bufptr + (len) <= dpy->bufmax) {\574memcpy(dpy->bufptr, data, (int)len);\575dpy->bufptr += ((len) + 3) & ~3;\576} else\577_XSend(dpy, data, len);\578}579#endif /* DataRoutineIsProcedure */580581582/* Allocate bytes from the buffer. No padding is done, so if583* the length is not a multiple of 4, the caller must be584* careful to leave the buffer aligned after sending the585* current request.586*587* "type" is the type of the pointer being assigned to.588* "ptr" is the pointer being assigned to.589* "n" is the number of bytes to allocate.590*591* Example:592* xTextElt *elt;593* BufAlloc (xTextElt *, elt, nbytes)594*/595596#define BufAlloc(type, ptr, n) \597if (dpy->bufptr + (n) > dpy->bufmax) \598_XFlush (dpy); \599ptr = (type) dpy->bufptr; \600memset(ptr, '\0', n); \601dpy->bufptr += (n);602603#ifdef WORD64604#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len)605#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)606#else607#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))608#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))609#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))610#ifdef LONG64611#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)612extern int _XData32(613Display *dpy,614register long *data,615unsigned len616);617extern void _XRead32(618Display *dpy,619register long *data,620long len621);622#else623#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))624#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))625#endif626#endif /* not WORD64 */627628#define PackData16(dpy,data,len) Data16 (dpy, data, len)629#define PackData32(dpy,data,len) Data32 (dpy, data, len)630631/* Xlib manual is bogus */632#define PackData(dpy,data,len) PackData16 (dpy, data, len)633634#define min(a,b) (((a) < (b)) ? (a) : (b))635#define max(a,b) (((a) > (b)) ? (a) : (b))636637#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \638(((cs)->rbearing|(cs)->lbearing| \639(cs)->ascent|(cs)->descent) == 0))640641/*642* CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit643* character. If the character is in the column and exists, then return the644* appropriate metrics (note that fonts with common per-character metrics will645* return min_bounds). If none of these hold true, try again with the default646* char.647*/648#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \649{ \650cs = def; \651if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \652if (fs->per_char == NULL) { \653cs = &fs->min_bounds; \654} else { \655cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \656if (CI_NONEXISTCHAR(cs)) cs = def; \657} \658} \659}660661#define CI_GET_DEFAULT_INFO_1D(fs,cs) \662CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)663664665666/*667* CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and668* column. This is used for fonts that have more than row zero.669*/670#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \671{ \672cs = def; \673if (row >= fs->min_byte1 && row <= fs->max_byte1 && \674col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \675if (fs->per_char == NULL) { \676cs = &fs->min_bounds; \677} else { \678cs = &fs->per_char[((row - fs->min_byte1) * \679(fs->max_char_or_byte2 - \680fs->min_char_or_byte2 + 1)) + \681(col - fs->min_char_or_byte2)]; \682if (CI_NONEXISTCHAR(cs)) cs = def; \683} \684} \685}686687#define CI_GET_DEFAULT_INFO_2D(fs,cs) \688{ \689unsigned int r = (fs->default_char >> 8); \690unsigned int c = (fs->default_char & 0xff); \691CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \692}693694695#ifdef MUSTCOPY696697/* for when 32-bit alignment is not good enough */698#define OneDataCard32(dpy,dstaddr,srcvar) \699{ dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); }700701#else702703/* srcvar must be a variable for large architecture version */704#define OneDataCard32(dpy,dstaddr,srcvar) \705{ *(CARD32 *)(dstaddr) = (srcvar); }706707#endif /* MUSTCOPY */708709typedef struct _XInternalAsync {710struct _XInternalAsync *next;711/*712* handler arguments:713* rep is the generic reply that caused this handler714* to be invoked. It must also be passed to _XGetAsyncReply.715* buf and len are opaque values that must be passed to716* _XGetAsyncReply or _XGetAsyncData.717* data is the closure stored in this struct.718* The handler returns True iff it handled this reply.719*/720Bool (*handler)(721Display* /* dpy */,722xReply* /* rep */,723char* /* buf */,724int /* len */,725XPointer /* data */726);727XPointer data;728} _XAsyncHandler;729730typedef struct _XAsyncEState {731unsigned long min_sequence_number;732unsigned long max_sequence_number;733unsigned char error_code;734unsigned char major_opcode;735unsigned short minor_opcode;736unsigned char last_error_received;737int error_count;738} _XAsyncErrorState;739740extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler);741#define DeqAsyncHandler(dpy,handler) { \742if (dpy->async_handlers == (handler)) \743dpy->async_handlers = (handler)->next; \744else \745_XDeqAsyncHandler(dpy, handler); \746}747748typedef void (*FreeFuncType) (749Display* /* display */750);751752typedef int (*FreeModmapType) (753XModifierKeymap* /* modmap */754);755756/*757* This structure is private to the library.758*/759typedef struct _XFreeFuncs {760FreeFuncType atoms; /* _XFreeAtomTable */761FreeModmapType modifiermap; /* XFreeModifiermap */762FreeFuncType key_bindings; /* _XFreeKeyBindings */763FreeFuncType context_db; /* _XFreeContextDB */764FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */765FreeFuncType clientCmaps; /* _XcmsFreeClientCmaps */766FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */767FreeFuncType im_filters; /* _XFreeIMFilters */768FreeFuncType xkb; /* _XkbFreeInfo */769} _XFreeFuncRec;770771/* types for InitExt.c */772typedef int (*CreateGCType) (773Display* /* display */,774GC /* gc */,775XExtCodes* /* codes */776);777778typedef int (*CopyGCType)(779Display* /* display */,780GC /* gc */,781XExtCodes* /* codes */782);783784typedef int (*FlushGCType) (785Display* /* display */,786GC /* gc */,787XExtCodes* /* codes */788);789790typedef int (*FreeGCType) (791Display* /* display */,792GC /* gc */,793XExtCodes* /* codes */794);795796typedef int (*CreateFontType) (797Display* /* display */,798XFontStruct* /* fs */,799XExtCodes* /* codes */800);801802typedef int (*FreeFontType) (803Display* /* display */,804XFontStruct* /* fs */,805XExtCodes* /* codes */806);807808typedef int (*CloseDisplayType) (809Display* /* display */,810XExtCodes* /* codes */811);812813typedef int (*ErrorType) (814Display* /* display */,815xError* /* err */,816XExtCodes* /* codes */,817int* /* ret_code */818);819820typedef char* (*ErrorStringType) (821Display* /* display */,822int /* code */,823XExtCodes* /* codes */,824char* /* buffer */,825int /* nbytes */826);827828typedef void (*PrintErrorType)(829Display* /* display */,830XErrorEvent* /* ev */,831void* /* fp */832);833834typedef void (*BeforeFlushType)(835Display* /* display */,836XExtCodes* /* codes */,837_Xconst char* /* data */,838long /* len */839);840841/*842* This structure is private to the library.843*/844typedef struct _XExten { /* private to extension mechanism */845struct _XExten *next; /* next in list */846XExtCodes codes; /* public information, all extension told */847CreateGCType create_GC; /* routine to call when GC created */848CopyGCType copy_GC; /* routine to call when GC copied */849FlushGCType flush_GC; /* routine to call when GC flushed */850FreeGCType free_GC; /* routine to call when GC freed */851CreateFontType create_Font; /* routine to call when Font created */852FreeFontType free_Font; /* routine to call when Font freed */853CloseDisplayType close_display; /* routine to call when connection closed */854ErrorType error; /* who to call when an error occurs */855ErrorStringType error_string; /* routine to supply error string */856char *name; /* name of this extension */857PrintErrorType error_values; /* routine to supply error values */858BeforeFlushType before_flush; /* routine to call when sending data */859struct _XExten *next_flush; /* next in list of those with flushes */860} _XExtension;861862/* Temporary definition until we can depend on an xproto release with it */863#ifdef _X_COLD864# define _XLIB_COLD _X_COLD865#elif defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403) /* 4.3+ */866# define _XLIB_COLD __attribute__((__cold__))867#else868# define _XLIB_COLD /* nothing */869#endif870871/* extension hooks */872873#ifdef DataRoutineIsProcedure874extern void Data(Display *dpy, char *data, long len);875#endif876extern int _XError(877Display* /* dpy */,878xError* /* rep */879);880extern int _XIOError(881Display* /* dpy */882) _X_NORETURN;883extern int (*_XIOErrorFunction)(884Display* /* dpy */885);886extern int (*_XErrorFunction)(887Display* /* dpy */,888XErrorEvent* /* error_event */889);890extern void _XEatData(891Display* /* dpy */,892unsigned long /* n */893) _XLIB_COLD;894#ifdef XLIB_WANT_XEATDATAWORDS895extern void _XEatDataWords(896Display* /* dpy */,897unsigned long /* n */898) _XLIB_COLD _X_HIDDEN;899#endif900#if defined(__SUNPRO_C) /* Studio compiler alternative to "cold" attribute */901# pragma rarely_called(_XEatData, _XEatDataWords)902#endif903extern char *_XAllocScratch(904Display* /* dpy */,905unsigned long /* nbytes */906);907extern char *_XAllocTemp(908Display* /* dpy */,909unsigned long /* nbytes */910);911extern void _XFreeTemp(912Display* /* dpy */,913char* /* buf */,914unsigned long /* nbytes */915);916extern Visual *_XVIDtoVisual(917Display* /* dpy */,918VisualID /* id */919);920extern unsigned long _XSetLastRequestRead(921Display* /* dpy */,922xGenericReply* /* rep */923);924extern int _XGetHostname(925char* /* buf */,926int /* maxlen */927);928extern Screen *_XScreenOfWindow(929Display* /* dpy */,930Window /* w */931);932extern Bool _XAsyncErrorHandler(933Display* /* dpy */,934xReply* /* rep */,935char* /* buf */,936int /* len */,937XPointer /* data */938);939extern char *_XGetAsyncReply(940Display* /* dpy */,941char* /* replbuf */,942xReply* /* rep */,943char* /* buf */,944int /* len */,945int /* extra */,946Bool /* discard */947);948extern void _XGetAsyncData(949Display* /* dpy */,950char * /* data */,951char * /* buf */,952int /* len */,953int /* skip */,954int /* datalen */,955int /* discardtotal */956);957extern void _XFlush(958Display* /* dpy */959);960extern int _XEventsQueued(961Display* /* dpy */,962int /* mode */963);964extern void _XReadEvents(965Display* /* dpy */966);967extern int _XRead(968Display* /* dpy */,969char* /* data */,970long /* size */971);972extern void _XReadPad(973Display* /* dpy */,974char* /* data */,975long /* size */976);977extern void _XSend(978Display* /* dpy */,979_Xconst char* /* data */,980long /* size */981);982extern Status _XReply(983Display* /* dpy */,984xReply* /* rep */,985int /* extra */,986Bool /* discard */987);988extern void _XEnq(989Display* /* dpy */,990xEvent* /* event */991);992extern void _XDeq(993Display* /* dpy */,994_XQEvent* /* prev */,995_XQEvent* /* qelt */996);997998extern Bool _XUnknownWireEvent(999Display* /* dpy */,1000XEvent* /* re */,1001xEvent* /* event */1002);10031004extern Bool _XUnknownWireEventCookie(1005Display* /* dpy */,1006XGenericEventCookie* /* re */,1007xEvent* /* event */1008);10091010extern Bool _XUnknownCopyEventCookie(1011Display* /* dpy */,1012XGenericEventCookie* /* in */,1013XGenericEventCookie* /* out */1014);10151016extern Status _XUnknownNativeEvent(1017Display* /* dpy */,1018XEvent* /* re */,1019xEvent* /* event */1020);10211022extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event);1023extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we);1024extern Bool _XPollfdCacheInit(Display *dpy);1025extern void _XPollfdCacheAdd(Display *dpy, int fd);1026extern void _XPollfdCacheDel(Display *dpy, int fd);1027extern XID _XAllocID(Display *dpy);1028extern void _XAllocIDs(Display *dpy, XID *ids, int count);10291030extern int _XFreeExtData(1031XExtData* /* extension */1032);10331034extern int (*XESetCreateGC(1035Display* /* display */,1036int /* extension */,1037int (*) (1038Display* /* display */,1039GC /* gc */,1040XExtCodes* /* codes */1041) /* proc */1042))(1043Display*, GC, XExtCodes*1044);10451046extern int (*XESetCopyGC(1047Display* /* display */,1048int /* extension */,1049int (*) (1050Display* /* display */,1051GC /* gc */,1052XExtCodes* /* codes */1053) /* proc */1054))(1055Display*, GC, XExtCodes*1056);10571058extern int (*XESetFlushGC(1059Display* /* display */,1060int /* extension */,1061int (*) (1062Display* /* display */,1063GC /* gc */,1064XExtCodes* /* codes */1065) /* proc */1066))(1067Display*, GC, XExtCodes*1068);10691070extern int (*XESetFreeGC(1071Display* /* display */,1072int /* extension */,1073int (*) (1074Display* /* display */,1075GC /* gc */,1076XExtCodes* /* codes */1077) /* proc */1078))(1079Display*, GC, XExtCodes*1080);10811082extern int (*XESetCreateFont(1083Display* /* display */,1084int /* extension */,1085int (*) (1086Display* /* display */,1087XFontStruct* /* fs */,1088XExtCodes* /* codes */1089) /* proc */1090))(1091Display*, XFontStruct*, XExtCodes*1092);10931094extern int (*XESetFreeFont(1095Display* /* display */,1096int /* extension */,1097int (*) (1098Display* /* display */,1099XFontStruct* /* fs */,1100XExtCodes* /* codes */1101) /* proc */1102))(1103Display*, XFontStruct*, XExtCodes*1104);11051106extern int (*XESetCloseDisplay(1107Display* /* display */,1108int /* extension */,1109int (*) (1110Display* /* display */,1111XExtCodes* /* codes */1112) /* proc */1113))(1114Display*, XExtCodes*1115);11161117extern int (*XESetError(1118Display* /* display */,1119int /* extension */,1120int (*) (1121Display* /* display */,1122xError* /* err */,1123XExtCodes* /* codes */,1124int* /* ret_code */1125) /* proc */1126))(1127Display*, xError*, XExtCodes*, int*1128);11291130extern char* (*XESetErrorString(1131Display* /* display */,1132int /* extension */,1133char* (*) (1134Display* /* display */,1135int /* code */,1136XExtCodes* /* codes */,1137char* /* buffer */,1138int /* nbytes */1139) /* proc */1140))(1141Display*, int, XExtCodes*, char*, int1142);11431144extern void (*XESetPrintErrorValues (1145Display* /* display */,1146int /* extension */,1147void (*)(1148Display* /* display */,1149XErrorEvent* /* ev */,1150void* /* fp */1151) /* proc */1152))(1153Display*, XErrorEvent*, void*1154);11551156extern Bool (*XESetWireToEvent(1157Display* /* display */,1158int /* event_number */,1159Bool (*) (1160Display* /* display */,1161XEvent* /* re */,1162xEvent* /* event */1163) /* proc */1164))(1165Display*, XEvent*, xEvent*1166);11671168extern Bool (*XESetWireToEventCookie(1169Display* /* display */,1170int /* extension */,1171Bool (*) (1172Display* /* display */,1173XGenericEventCookie* /* re */,1174xEvent* /* event */1175) /* proc */1176))(1177Display*, XGenericEventCookie*, xEvent*1178);11791180extern Bool (*XESetCopyEventCookie(1181Display* /* display */,1182int /* extension */,1183Bool (*) (1184Display* /* display */,1185XGenericEventCookie* /* in */,1186XGenericEventCookie* /* out */1187) /* proc */1188))(1189Display*, XGenericEventCookie*, XGenericEventCookie*1190);119111921193extern Status (*XESetEventToWire(1194Display* /* display */,1195int /* event_number */,1196Status (*) (1197Display* /* display */,1198XEvent* /* re */,1199xEvent* /* event */1200) /* proc */1201))(1202Display*, XEvent*, xEvent*1203);12041205extern Bool (*XESetWireToError(1206Display* /* display */,1207int /* error_number */,1208Bool (*) (1209Display* /* display */,1210XErrorEvent* /* he */,1211xError* /* we */1212) /* proc */1213))(1214Display*, XErrorEvent*, xError*1215);12161217extern void (*XESetBeforeFlush(1218Display* /* display */,1219int /* error_number */,1220void (*) (1221Display* /* display */,1222XExtCodes* /* codes */,1223_Xconst char* /* data */,1224long /* len */1225) /* proc */1226))(1227Display*, XExtCodes*, _Xconst char*, long1228);12291230/* internal connections for IMs */12311232typedef void (*_XInternalConnectionProc)(1233Display* /* dpy */,1234int /* fd */,1235XPointer /* call_data */1236);123712381239extern Status _XRegisterInternalConnection(1240Display* /* dpy */,1241int /* fd */,1242_XInternalConnectionProc /* callback */,1243XPointer /* call_data */1244);12451246extern void _XUnregisterInternalConnection(1247Display* /* dpy */,1248int /* fd */1249);12501251extern void _XProcessInternalConnection(1252Display* /* dpy */,1253struct _XConnectionInfo* /* conn_info */1254);12551256/* Display structure has pointers to these */12571258struct _XConnectionInfo { /* info from _XRegisterInternalConnection */1259int fd;1260_XInternalConnectionProc read_callback;1261XPointer call_data;1262XPointer *watch_data; /* set/used by XConnectionWatchProc */1263struct _XConnectionInfo *next;1264};12651266struct _XConnWatchInfo { /* info from XAddConnectionWatch */1267XConnectionWatchProc fn;1268XPointer client_data;1269struct _XConnWatchInfo *next;1270};12711272#ifdef __UNIXOS2__1273extern char* __XOS2RedirRoot(1274char*1275);1276#endif12771278extern int _XTextHeight(1279XFontStruct* /* font_struct */,1280_Xconst char* /* string */,1281int /* count */1282);12831284extern int _XTextHeight16(1285XFontStruct* /* font_struct */,1286_Xconst XChar2b* /* string */,1287int /* count */1288);12891290#if defined(WIN32)12911292extern int _XOpenFile(1293_Xconst char* /* path */,1294int /* flags */1295);12961297extern int _XOpenFileMode(1298_Xconst char* /* path */,1299int /* flags */,1300mode_t /* mode */1301);13021303extern void* _XFopenFile(1304_Xconst char* /* path */,1305_Xconst char* /* mode */1306);13071308extern int _XAccessFile(1309_Xconst char* /* path */1310);1311#else1312#define _XOpenFile(path,flags) open(path,flags)1313#define _XOpenFileMode(path,flags,mode) open(path,flags,mode)1314#define _XFopenFile(path,mode) fopen(path,mode)1315#endif13161317/* EvToWire.c */1318extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event);13191320extern int _XF86LoadQueryLocaleFont(1321Display* /* dpy */,1322_Xconst char* /* name*/,1323XFontStruct** /* xfp*/,1324Font* /* fidp */1325);13261327extern void _XProcessWindowAttributes (1328register Display *dpy,1329xChangeWindowAttributesReq *req,1330register unsigned long valuemask,1331register XSetWindowAttributes *attributes);13321333extern int _XDefaultError(1334Display *dpy,1335XErrorEvent *event);13361337extern int _XDefaultIOError(1338Display *dpy);13391340extern void _XSetClipRectangles (1341register Display *dpy,1342GC gc,1343int clip_x_origin, int clip_y_origin,1344XRectangle *rectangles,1345int n,1346int ordering);13471348Status _XGetWindowAttributes(1349register Display *dpy,1350Window w,1351XWindowAttributes *attr);13521353int _XPutBackEvent (1354register Display *dpy,1355register XEvent *event);13561357extern Bool _XIsEventCookie(1358Display *dpy,1359XEvent *ev);13601361extern void _XFreeEventCookies(1362Display *dpy);13631364extern void _XStoreEventCookie(1365Display *dpy,1366XEvent *ev);13671368extern Bool _XFetchEventCookie(1369Display *dpy,1370XGenericEventCookie *ev);13711372extern Bool _XCopyEventCookie(1373Display *dpy,1374XGenericEventCookie *in,1375XGenericEventCookie *out);13761377/* lcFile.c */13781379extern void xlocaledir(1380char *buf,1381int buf_len1382);13831384_XFUNCPROTOEND13851386#endif /* _X11_XLIBINT_H_ */138713881389