1 module x11.extensions.XI2;
2 
3 version(Posix):
4 
5 import std.string;
6 
7 extern (C) nothrow:
8 
9 /* Indices into the versions[] array (XExtInt.c). Used as a index to
10  * retrieve the minimum version of XI from _XiCheckExtInit.
11  * For indices 0 to 6 see XI.h */
12 const uint Dont_Check = 0;
13 const uint XInput_2_0 = 7;
14 
15 
16 const uint XI_2_Major = 2;
17 const uint XI_2_Minor = 0;
18 
19 /* Property event flags */
20 enum {
21     XIPropertyDeleted  = 0,
22     XIPropertyCreated  = 1,
23     XIPropertyModified = 2
24 }
25 
26 /* Enter/Leave and Focus In/Out modes */
27 enum {
28     XINotifyNormal        = 0,
29     XINotifyGrab          = 1,
30     XINotifyUngrab        = 2,
31     XINotifyWhileGrabbed  = 3,
32     XINotifyPassiveGrab   = 4,
33     XINotifyPassiveUngrab = 5
34 }
35 
36 /* Enter/Leave and focus In/out detail */
37 enum {
38     XINotifyAncestor         = 0,
39     XINotifyVirtual          = 1,
40     XINotifyInferior         = 2,
41     XINotifyNonlinear        = 3,
42     XINotifyNonlinearVirtual = 4,
43     XINotifyPointer          = 5,
44     XINotifyPointerRoot      = 6,
45     XINotifyDetailNone       = 7
46 }
47 
48 /* Passive grab types */
49 enum {
50     XIGrabtypeButton  = 0,
51     XIGrabtypeKeycode = 1,
52     XIGrabtypeEnter   = 2,
53     XIGrabtypeFocusIn = 3
54 }
55 
56 /* Passive grab modifier */
57 enum {
58     XIAnyModifier  = 1U << 31,
59     XIAnyButton    = 0,
60     XIAnyKeycode   = 0
61 }
62 
63 /* XIAllowEvents event-modes */
64 enum {
65     XIAsyncDevice       = 0,
66     XISyncDevice        = 1,
67     XIReplayDevice      = 2,
68     XIAsyncPairedDevice = 3,
69     XIAsyncPair         = 4,
70     XISyncPair          = 5
71 }
72 
73 /* DeviceChangedEvent change reasons */
74 enum {
75     XISlaveSwitch  = 1,
76     XIDeviceChange = 2
77 }
78 
79 /* Hierarchy flags */
80 enum {
81     XIMasterAdded    = 1 << 0,
82     XIMasterRemoved  = 1 << 1,
83     XISlaveAdded     = 1 << 2,
84     XISlaveRemoved   = 1 << 3,
85     XISlaveAttached  = 1 << 4,
86     XISlaveDetached  = 1 << 5,
87     XIDeviceEnabled  = 1 << 6,
88     XIDeviceDisabled = 1 << 7
89 }
90 
91 /* ChangeHierarchy constants */
92 enum {
93     XIAddMaster    = 1,
94     XIRemoveMaster = 2,
95     XIAttachSlave  = 3,
96     XIDetachSlave  = 4
97 }
98 
99 const int XIAttachToMaster = 1;
100 const int XIFloating       = 2;
101 
102 /* Valuator modes */
103 enum {
104     XIModeRelative = 0,
105     XIModeAbsolute = 1
106 }
107 
108 /* Device types */
109 enum {
110     XIMasterPointer  = 1,
111     XIMasterKeyboard = 2,
112     XISlavePointer   = 3,
113     XISlaveKeyboard  = 4,
114     XIFloatingSlave  = 5
115 }
116 
117 /* Device classes */
118 enum {
119     XIKeyClass      = 0,
120     XIButtonClass   = 1,
121     XIValuatorClass = 2
122 }
123 
124 /* Device event flags (common) */
125 /* Device event flags (key events only) */
126 const int XIKeyRepeat = 1 << 16;
127 /* Device event flags (pointer events only) */
128 
129 /* XI2 event mask macros */
130 template XISetMask(string ptr, int event){
131     const ubyte XISetMask = cast(ubyte)(ptr[(event)>>3] |=  (1 << ((event) & 7)));
132 }
133 
134 template XIClearMask(string ptr, int event){
135     const ubyte XIClearMask = cast(ubyte)(ptr[(event)>>3] &= ~(1 << ((event) & 7)));
136 }
137 
138 template XIMaskIsSet(string ptr, int event){
139     const ubyte XIMaskIsSet = cast(ubyte)(ptr[(event)>>3] &   (1 << ((event) & 7)));
140 }
141 
142 template XIMaskLen(int event){
143     const ubyte XIMaskLen = (((event) >> 3) + 1);
144 }
145 
146 /* Fake device ID's for event selection */
147 enum {
148     XIAllDevices       = 0,
149     XIAllMasterDevices = 1
150 }
151 
152 /* Event types */
153 enum {
154     XI_DeviceChanged    = 1,
155     XI_KeyPress         = 2,
156     XI_KeyRelease       = 3,
157     XI_ButtonPress      = 4,
158     XI_ButtonRelease    = 5,
159     XI_Motion           = 6,
160     XI_Enter            = 7,
161     XI_Leave            = 8,
162     XI_FocusIn          = 9,
163     XI_FocusOut         = 10,
164     XI_HierarchyChanged = 11,
165     XI_PropertyEvent    = 12,
166     XI_RawKeyPress      = 13,
167     XI_RawKeyRelease    = 14,
168     XI_RawButtonPress   = 15,
169     XI_RawButtonRelease = 16,
170     XI_RawMotion        = 17,
171     XI_LASTEVENT        = XI_RawMotion
172 }
173 /* NOTE: XI2LASTEVENT in xserver/include/inputstr.h must be the same value
174  * as XI_LASTEVENT if the server is supposed to handle masks etc. for this
175  * type of event. */
176 
177 /* Event masks.
178  * Note: the protocol spec defines a mask to be of (1 << type). Clients are
179  * free to create masks by bitshifting instead of using these defines.
180  */
181  enum {
182     XI_DeviceChangedMask    = (1 << XI_DeviceChanged),
183     XI_KeyPressMask         = (1 << XI_KeyPress),
184     XI_KeyReleaseMask       = (1 << XI_KeyRelease),
185     XI_ButtonPressMask      = (1 << XI_ButtonPress),
186     XI_ButtonReleaseMask    = (1 << XI_ButtonRelease),
187     XI_MotionMask           = (1 << XI_Motion),
188     XI_EnterMask            = (1 << XI_Enter),
189     XI_LeaveMask            = (1 << XI_Leave),
190     XI_FocusInMask          = (1 << XI_FocusIn),
191     XI_FocusOutMask         = (1 << XI_FocusOut),
192     XI_HierarchyChangedMask = (1 << XI_HierarchyChanged),
193     XI_PropertyEventMask    = (1 << XI_PropertyEvent),
194     XI_RawKeyPressMask      = (1 << XI_RawKeyPress),
195     XI_RawKeyReleaseMask    = (1 << XI_RawKeyRelease),
196     XI_RawButtonPressMask   = (1 << XI_RawButtonPress),
197     XI_RawButtonReleaseMask = (1 << XI_RawButtonRelease),
198     XI_RawMotionMask        = (1 << XI_RawMotion)
199 }