XIint.h revision 06c34b88
1/* 2 * XIint.h - Header definition and support file for the internal 3 * support routines used by the Xi library. 4 */ 5 6#ifndef _XIINT_H_ 7#define _XIINT_H_ 8#include <X11/extensions/XI.h> 9 10/* inputproto 2.0 still shipped with these defined in the proto headers */ 11#ifndef XInput_Initial_Release 12/* Indices into the versions[] array (XExtInt.c). Used as a index to 13 * retrieve the minimum version of XI from _XiCheckExtInit */ 14#define Dont_Check 0 15#define XInput_Initial_Release 1 16#define XInput_Add_XDeviceBell 2 17#define XInput_Add_XSetDeviceValuators 3 18#define XInput_Add_XChangeDeviceControl 4 19#define XInput_Add_DevicePresenceNotify 5 20#define XInput_Add_DeviceProperties 6 21#define XInput_2_0 7 22#endif 23#define XInput_2_1 8 24#define XInput_2_2 9 25#define XInput_2_3 10 26 27extern XExtDisplayInfo *XInput_find_display(Display *); 28 29extern int _XiCheckExtInit(Display *, int, XExtDisplayInfo *); 30extern int _XiCheckVersion(XExtDisplayInfo *info, int version_index); 31 32extern XExtensionVersion *_XiGetExtensionVersion(Display *, _Xconst char *, XExtDisplayInfo *); 33extern XExtensionVersion* _XiGetExtensionVersionRequest(Display *dpy, _Xconst char *name, int xi_opcode); 34extern Status _xiQueryVersion(Display *dpy, int*, int*, XExtDisplayInfo *); 35 36extern Status _XiEventToWire( 37 register Display * /* dpy */, 38 register XEvent * /* re */, 39 register xEvent ** /* event */, 40 register int * /* count */ 41); 42 43typedef struct _XInputData 44{ 45 XEvent data; 46 XExtensionVersion *vers; 47} XInputData; 48 49 50/** 51 * Returns the next valid memory block of the given size within the block 52 * previously allocated. 53 * Use letting pointers inside a struct point to bytes after the same 54 * struct, e.g. during protocol parsing etc. 55 * 56 * Caller is responsible for allocating enough memory. 57 * 58 * Example: 59 * void *ptr; 60 * struct foo { 61 * int num_a; 62 * int num_b; 63 * int *a; 64 * int *b; 65 * } bar; 66 * 67 * ptr = malloc(large_enough); 68 * bar = next_block(&ptr, sizeof(struct foo)); 69 * bar->num_a = 10; 70 * bar->num_b = 20; 71 * bar->a = next_block(&ptr, bar->num_a); 72 * bar->b = next_block(&ptr, bar->num_b); 73 */ 74static inline void* 75next_block(void **ptr, int size) { 76 void *ret = *ptr; 77 78 if (!*ptr) 79 return NULL; 80 81 *(unsigned char**)ptr += size; 82 83 return ret; 84} 85 86#ifndef HAVE__XEATDATAWORDS 87#include <X11/Xmd.h> /* for LONG64 on 64-bit platforms */ 88#include <limits.h> 89 90static inline void _XEatDataWords(Display *dpy, unsigned long n) 91{ 92# ifndef LONG64 93 if (n >= (ULONG_MAX >> 2)) 94 _XIOError(dpy); 95# endif 96 _XEatData (dpy, n << 2); 97} 98#endif 99 100#endif 101