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 #define XInput_2_4 11 27 28 extern XExtDisplayInfo *XInput_find_display(Display *); 29 30 extern int _XiCheckExtInit(Display *, int, XExtDisplayInfo *); 31 extern int _XiCheckVersion(XExtDisplayInfo *info, int version_index); 32 33 extern XExtensionVersion* _XiGetExtensionVersionRequest(Display *dpy, _Xconst char *name, int xi_opcode); 34 extern Status _xiQueryVersion(Display *dpy, int*, int*, XExtDisplayInfo *); 35 36 extern Status _XiEventToWire( 37 register Display * /* dpy */, 38 register XEvent * /* re */, 39 register xEvent ** /* event */, 40 register int * /* count */ 41 ); 42 43 typedef 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 */ 74 static inline void* 75 next_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 87 #endif 88