Add action datatypes as defined in the server
[platform/upstream/libxkbcommon.git] / include / X11 / extensions / XKBcommon.h
1 /*
2 Copyright 1985, 1987, 1990, 1998  The Open Group
3 Copyright 2008  Dan Nicholson
4
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 and/or sell copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the names of the authors or their
23 institutions shall not be used in advertising or otherwise to promote the
24 sale, use or other dealings in this Software without prior written
25 authorization from the authors.
26 */
27
28 #ifndef _XKBCOMMON_H_
29 #define _XKBCOMMON_H_
30
31 #include <stdio.h>
32 #include <X11/X.h>
33 #include <X11/Xdefs.h>
34 #include <X11/Xfuncproto.h>
35 #include <X11/extensions/XKBstrcommon.h>
36 #include <X11/extensions/XKBgeomcommon.h>
37 #include <X11/extensions/XKBrulescommon.h>
38
39 /* Action structures used in the server */
40 typedef struct _XkbcModAction {
41     unsigned char   type;
42     unsigned char   flags;
43     unsigned char   mask;
44     unsigned char   real_mods;
45     unsigned int    vmods;
46 } XkbcModAction;
47
48 typedef struct _XkbcISOAction {
49     unsigned char   type;
50     unsigned char   flags;
51     unsigned char   mask;
52     unsigned char   real_mods;
53     /* FIXME: Make this an int. */
54     char            group_XXX;
55     unsigned char   affect;
56     unsigned int    vmods;
57 } XkbcISOAction;
58
59 typedef struct _XkbcPtrAction {
60     unsigned char   type;
61     unsigned char   flags;
62     int             x;
63     int             y;
64 } XkbcPtrAction;
65
66 typedef struct _XkbcCtrlsAction {
67     unsigned char   type;
68     unsigned char   flags;
69     unsigned long   ctrls;
70 } XkbcCtrlsAction;
71
72 typedef struct  _XkbcRedirectKeyAction {
73     unsigned char   type;
74     unsigned char   new_key;
75     unsigned char   mods_mask;
76     unsigned char   mods;
77     unsigned int    vmods_mask;
78     unsigned int    vmods;
79 } XkbcRedirectKeyAction;
80
81 typedef union _XkbcAction {
82     XkbAnyAction            any;
83     XkbcModAction           mods;
84     XkbGroupAction          group;
85     XkbcISOAction           iso;
86     XkbcPtrAction           ptr;
87     XkbPtrBtnAction         btn;
88     XkbPtrDfltAction        dflt;
89     XkbSwitchScreenAction   screen;
90     XkbcCtrlsAction         ctrls;
91     XkbMessageAction        msg;
92     XkbcRedirectKeyAction   redirect;
93     XkbDeviceBtnAction      devbtn;
94     XkbDeviceValuatorAction devval;
95     unsigned char           type;
96 } XkbcAction;
97
98 typedef struct _XkbcServerMapRec {
99     unsigned short      num_acts;
100     unsigned short      size_acts;
101     XkbcAction *        acts;
102
103     XkbBehavior *       behaviors;
104     unsigned short *    key_acts;
105 #if defined(__cplusplus) || defined(c_plusplus)
106     /* explicit is a C++ reserved word */
107     unsigned char *     c_explicit;
108 #else
109     unsigned char *     explicit;
110 #endif
111     unsigned char       vmods[XkbNumVirtualMods];
112     unsigned short *    vmodmap;
113 } XkbcServerMapRec, *XkbcServerMapPtr;
114
115 /* Common keyboard description structure */
116 typedef struct _XkbcDesc {
117     unsigned int        defined;
118     unsigned short      flags;
119     unsigned short      device_spec;
120     KeyCode             min_key_code;
121     KeyCode             max_key_code;
122
123     XkbControlsPtr      ctrls;
124     XkbcServerMapPtr    server;
125     XkbClientMapPtr     map;
126     XkbIndicatorPtr     indicators;
127     XkbNamesPtr         names;
128     XkbCompatMapPtr     compat;
129     XkbGeometryPtr      geom;
130 } XkbcDescRec, *XkbcDescPtr;
131
132 #define _XkbcKSLower (1 << 0)
133 #define _XkbcKSUpper (1 << 1)
134
135 #define XkbcKSIsLower(k) (_XkbcKSCheckCase(k) & _XkbcKSLower)
136 #define XkbcKSIsUpper(k) (_XkbcKSCheckCase(k) & _XkbcKSUpper)
137 #define XkbcKSIsKeypad(k) \
138     (((k) >= XK_KP_Space) && ((k) <= XK_KP_Equal))
139 #define XkbcKSIsDeadKey(k) \
140     (((k) >= XK_dead_grave) && ((k) <= XK_dead_semivoiced_sound))
141
142 _XFUNCPROTOBEGIN
143
144 extern XkbcDescPtr
145 XkbcCompileKeymapFromRules(const char *rules, XkbRF_VarDefsPtr defs);
146
147 extern XkbcDescPtr
148 XkbcCompileKeymapFromComponents(XkbComponentNamesPtr ktcsg);
149
150 extern char *
151 XkbcKeysymToString(KeySym ks);
152
153 extern KeySym
154 XkbcStringToKeysym(const char *s);
155
156 extern int
157 XkbcAllocCompatMap(XkbcDescPtr xkb, unsigned which, unsigned nSI);
158
159 extern void
160 XkbcFreeCompatMap(XkbcDescPtr xkb, unsigned which, Bool freeMap);
161
162 extern int
163 XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases);
164
165 extern void
166 XkbcFreeNames(XkbcDescPtr xkb, unsigned which, Bool freeMap);
167
168 extern int
169 XkbcAllocControls(XkbcDescPtr xkb, unsigned which);
170
171 extern void
172 XkbcFreeControls(XkbcDescPtr xkb, unsigned which, Bool freeMap);
173
174 extern int
175 XkbcAllocIndicatorMaps(XkbcDescPtr xkb);
176
177 extern void
178 XkbcFreeIndicatorMaps(XkbcDescPtr xkb);
179
180 extern XkbcDescRec *
181 XkbcAllocKeyboard(void);
182
183 extern void
184 XkbcFreeKeyboard(XkbcDescPtr xkb, unsigned which, Bool freeAll);
185
186 extern int
187 XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes);
188
189 extern int
190 XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions);
191
192 extern int
193 XkbcCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into);
194
195 extern int
196 XkbcCopyKeyTypes(XkbKeyTypePtr from, XkbKeyTypePtr into, int num_types);
197
198 extern int
199 XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
200                   Bool want_preserve, int new_num_lvls);
201
202 extern KeySym *
203 XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed);
204
205 extern int
206 XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
207                        XkbChangesPtr changes);
208
209 extern XkbcAction *
210 XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed);
211
212 extern void
213 XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
214
215 extern void
216 XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
217
218 extern void
219 XkbcFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll);
220
221 extern void
222 XkbcFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll);
223
224 extern void
225 XkbcFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll);
226
227 extern void
228 XkbcFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll);
229
230 extern void
231 XkbcFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll);
232
233 extern void
234 XkbcFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll);
235
236 extern void
237 XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count,
238                         Bool freeAll);
239
240 extern void
241 XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
242                         Bool freeAll);
243
244 extern void
245 XkbcFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll);
246
247 extern void
248 XkbcFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll);
249
250 extern void
251 XkbcFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll);
252
253 extern void
254 XkbcFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll);
255
256 extern void
257 XkbcFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll);
258
259 extern void
260 XkbcFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap);
261
262 extern int
263 XkbcAllocGeomProps(XkbGeometryPtr geom, int nProps);
264
265 extern int
266 XkbcAllocGeomColors(XkbGeometryPtr geom, int nColors);
267
268 extern int
269 XkbcAllocGeomKeyAliases(XkbGeometryPtr geom, int nKeyAliases);
270
271 extern int
272 XkbcAllocGeomShapes(XkbGeometryPtr geom, int nShapes);
273
274 extern int
275 XkbcAllocGeomSections(XkbGeometryPtr geom, int nSections);
276
277 extern int
278 XkbcAllocGeomOverlays(XkbSectionPtr section, int nOverlays);
279
280 extern int
281 XkbcAllocGeomOverlayRows(XkbOverlayPtr overlay, int nRows);
282
283 extern int
284 XkbcAllocGeomOverlayKeys(XkbOverlayRowPtr row, int nKeys);
285
286 extern int
287 XkbcAllocGeomDoodads(XkbGeometryPtr geom, int nDoodads);
288
289 extern int
290 XkbcAllocGeomSectionDoodads(XkbSectionPtr section, int nDoodads);
291
292 extern int
293 XkbcAllocGeomOutlines(XkbShapePtr shape, int nOL);
294
295 extern int
296 XkbcAllocGeomRows(XkbSectionPtr section, int nRows);
297
298 extern int
299 XkbcAllocGeomPoints(XkbOutlinePtr ol, int nPts);
300
301 extern int
302 XkbcAllocGeomKeys(XkbRowPtr row, int nKeys);
303
304 extern int
305 XkbcAllocGeometry(XkbcDescPtr xkb, XkbGeometrySizesPtr sizes);
306
307 extern XkbPropertyPtr
308 XkbcAddGeomProperty(XkbGeometryPtr geom, char *name, char *value);
309
310 extern XkbKeyAliasPtr
311 XkbcAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr);
312
313 extern XkbColorPtr
314 XkbcAddGeomColor(XkbGeometryPtr geom, char *spec, unsigned int pixel);
315
316 extern XkbOutlinePtr
317 XkbcAddGeomOutline(XkbShapePtr shape, int sz_points);
318
319 extern XkbShapePtr
320 XkbcAddGeomShape(XkbGeometryPtr geom, Atom name, int sz_outlines);
321
322 extern XkbKeyPtr
323 XkbcAddGeomKey(XkbRowPtr row);
324
325 extern XkbRowPtr
326 XkbcAddGeomRow(XkbSectionPtr section, int sz_keys);
327
328 extern XkbSectionPtr
329 XkbcAddGeomSection(XkbGeometryPtr geom, Atom name,
330                    int sz_rows, int sz_doodads, int sz_over);
331
332 extern XkbDoodadPtr
333 XkbcAddGeomDoodad(XkbGeometryPtr geom, XkbSectionPtr section, Atom name);
334
335 extern XkbOverlayKeyPtr
336 XkbcAddGeomOverlayKey(XkbOverlayPtr overlay, XkbOverlayRowPtr row,
337                       char *over, char *under);
338
339 extern XkbOverlayRowPtr
340 XkbcAddGeomOverlayRow(XkbOverlayPtr overlay, int row_under, int sz_keys);
341
342 extern XkbOverlayPtr
343 XkbcAddGeomOverlay(XkbSectionPtr section, Atom name, int sz_rows);
344
345 extern void
346 XkbcInitAtoms(void);
347
348 extern char *
349 XkbcAtomGetString(Atom atom);
350
351 extern Atom
352 XkbcInternAtom(char *name, Bool onlyIfExists);
353
354 extern char *
355 XkbcAtomText(Atom atm);
356
357 extern char *
358 XkbcVModIndexText(XkbcDescPtr xkb, unsigned ndx);
359
360 extern char *
361 XkbcVModMaskText(XkbcDescPtr xkb, unsigned modMask, unsigned mask);
362
363 extern char *
364 XkbcModIndexText(unsigned ndx);
365
366 extern char *
367 XkbcModMaskText(unsigned mask, Bool cFormat);
368
369 extern char *
370 XkbcConfigText(unsigned config);
371
372 extern char *
373 XkbcGeomFPText(int val);
374
375 extern char *
376 XkbcActionTypeText(unsigned type);
377
378 extern char *
379 XkbcKeysymText(KeySym sym);
380
381 extern char *
382 XkbcKeyNameText(char *name);
383
384 extern char *
385 XkbcSIMatchText(unsigned type);
386
387 extern Bool
388 XkbcComputeShapeBounds(XkbShapePtr shape);
389
390 extern Bool
391 XkbcComputeShapeTop(XkbShapePtr shape, XkbBoundsPtr bounds);
392
393 extern Bool
394 XkbcComputeRowBounds(XkbGeometryPtr geom, XkbSectionPtr section, XkbRowPtr row);
395
396 extern Bool
397 XkbcComputeSectionBounds(XkbGeometryPtr geom, XkbSectionPtr section);
398
399 extern Bool
400 XkbcRF_GetComponents(XkbRF_RulesPtr rules, XkbRF_VarDefsPtr defs,
401                      XkbComponentNamesPtr names);
402
403 extern XkbRF_RulePtr
404 XkbcRF_AddRule(XkbRF_RulesPtr rules);
405
406 extern XkbRF_GroupPtr
407 XkbcRF_AddGroup(XkbRF_RulesPtr rules);
408
409 extern Bool
410 XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
411
412 extern Bool
413 XkbcRF_LoadRulesByName(char *base, char *locale, XkbRF_RulesPtr rules);
414
415 extern XkbRF_VarDescPtr
416 XkbcRF_AddVarDesc(XkbRF_DescribeVarsPtr vars);
417
418 extern XkbRF_VarDescPtr
419 XkbcRF_AddVarDescCopy(XkbRF_DescribeVarsPtr vars, XkbRF_VarDescPtr from);
420
421 extern XkbRF_DescribeVarsPtr
422 XkbcRF_AddVarToDescribe(XkbRF_RulesPtr rules, char *name);
423
424 extern Bool
425 XkbcRF_LoadDescriptions(FILE *file, XkbRF_RulesPtr rules);
426
427 extern Bool
428 XkbcRF_LoadDescriptionsByName(char *base, char *locale, XkbRF_RulesPtr rules);
429
430 extern XkbRF_RulesPtr
431 XkbcRF_Load(char *base, char *locale, Bool wantDesc, Bool wantRules);
432
433 extern XkbRF_RulesPtr
434 XkbcRF_Create(int szRules, int szExtra);
435
436 extern void
437 XkbcRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
438
439 extern int
440 XkbcInitCanonicalKeyTypes(XkbcDescPtr xkb, unsigned which, int keypadVMod);
441
442 extern Bool
443 XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask,
444                       unsigned *mask_rtrn);
445
446 extern Bool
447 XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
448                         unsigned char *map_rtrn);
449
450 extern void
451 XkbcEnsureSafeMapName(char *name);
452
453 extern unsigned
454 _XkbcKSCheckCase(KeySym sym);
455
456 _XFUNCPROTOEND
457
458 #endif /* _XKBCOMMON_H_ */