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