Imported Upstream version 1.6.1
[platform/upstream/libXi.git] / src / XIint.h
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
26 extern XExtDisplayInfo *XInput_find_display(Display *);
27
28 extern int _XiCheckExtInit(Display *, int, XExtDisplayInfo *);
29 extern int _XiCheckVersion(XExtDisplayInfo *info, int version_index);
30
31 extern XExtensionVersion *_XiGetExtensionVersion(Display *, _Xconst char *, XExtDisplayInfo *);
32 extern XExtensionVersion* _XiGetExtensionVersionRequest(Display *dpy, _Xconst char *name, int xi_opcode);
33 extern Status _xiQueryVersion(Display *dpy, int*, int*, XExtDisplayInfo *);
34
35 extern Status _XiEventToWire(
36     register Display *          /* dpy */,
37     register XEvent *           /* re */,
38     register xEvent **          /* event */,
39     register int *              /* count */
40 );
41
42 typedef struct _XInputData
43 {
44     XEvent data;
45     XExtensionVersion *vers;
46 } XInputData;
47
48
49 /**
50  * Returns the next valid memory block of the given size within the block
51  * previously allocated.
52  * Use letting pointers inside a struct point to bytes after the same
53  * struct, e.g. during protocol parsing etc.
54  *
55  * Caller is responsible for allocating enough memory.
56  *
57  * Example:
58  *    void *ptr;
59  *    struct foo {
60  *       int num_a;
61  *       int num_b;
62  *       int *a;
63  *       int *b;
64  *    } bar;
65  *
66  *    ptr = malloc(large_enough);
67  *    bar = next_block(&ptr, sizeof(struct foo));
68  *    bar->num_a = 10;
69  *    bar->num_b = 20;
70  *    bar->a = next_block(&ptr, bar->num_a);
71  *    bar->b = next_block(&ptr, bar->num_b);
72  */
73 static inline void*
74 next_block(void **ptr, int size) {
75     void *ret = *ptr;
76
77     if (!*ptr)
78         return NULL;
79
80     *(unsigned char**)ptr += size;
81
82     return ret;
83 }
84
85 #endif