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