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