Add XKBlib API to support keytypes
[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 <X11/X.h>
32 #include <X11/Xdefs.h>
33 #include <X11/Xfuncproto.h>
34 #include <X11/keysymdef.h>
35 #include <X11/extensions/XKBstrcommon.h>
36 #include <X11/extensions/XKBgeomcommon.h>
37
38 /* Common keyboard description structure */
39 typedef struct _XkbcDesc {
40     unsigned int        defined;
41     unsigned short      flags;
42     unsigned short      device_spec;
43     KeyCode             min_key_code;
44     KeyCode             max_key_code;
45
46     XkbControlsPtr      ctrls;
47     XkbServerMapPtr     server;
48     XkbClientMapPtr     map;
49     XkbIndicatorPtr     indicators;
50     XkbNamesPtr         names;
51     XkbCompatMapPtr     compat;
52     XkbGeometryPtr      geom;
53 } XkbcDescRec, *XkbcDescPtr;
54
55 #define XkbcKSIsKeypad(k) \
56     (((k) >= XK_KP_Space) && ((k) <= XK_KP_Equal))
57 #define XkbcKSIsDeadKey(k) \
58     (((k) >= XK_dead_grave) && ((k) <= XK_dead_semivoiced_sound))
59
60 _XFUNCPROTOBEGIN
61
62 extern char *
63 XkbcKeysymToString(KeySym ks);
64
65 extern KeySym
66 XkbcStringToKeysym(const char *s);
67
68 extern int
69 XkbcAllocCompatMap(XkbcDescPtr xkb, unsigned which, unsigned nSI);
70
71 extern void
72 XkbcFreeCompatMap(XkbcDescPtr xkb, unsigned which, Bool freeMap);
73
74 extern int
75 XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases);
76
77 extern void
78 XkbcFreeNames(XkbcDescPtr xkb, unsigned which, Bool freeMap);
79
80 extern int
81 XkbcAllocControls(XkbcDescPtr xkb, unsigned which);
82
83 extern void
84 XkbcFreeControls(XkbcDescPtr xkb, unsigned which, Bool freeMap);
85
86 extern int
87 XkbcAllocIndicatorMaps(XkbcDescPtr xkb);
88
89 extern void
90 XkbcFreeIndicatorMaps(XkbcDescPtr xkb);
91
92 extern XkbcDescRec *
93 XkbcAllocKeyboard(void);
94
95 extern void
96 XkbcFreeKeyboard(XkbcDescPtr xkb, unsigned which, Bool freeAll);
97
98 extern int
99 XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes);
100
101 extern int
102 XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions);
103
104 extern int
105 XkbcCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into);
106
107 extern int
108 XkbcCopyKeyTypes(XkbKeyTypePtr from, XkbKeyTypePtr into, int num_types);
109
110 extern void
111 XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
112
113 extern void
114 XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
115
116 extern void
117 XkbcFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll);
118
119 extern void
120 XkbcFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll);
121
122 extern void
123 XkbcFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll);
124
125 extern void
126 XkbcFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll);
127
128 extern void
129 XkbcFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll);
130
131 extern void
132 XkbcFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll);
133
134 extern void
135 XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count,
136                         Bool freeAll);
137
138 extern void
139 XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
140                         Bool freeAll);
141
142 extern void
143 XkbcFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll);
144
145 extern void
146 XkbcFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll);
147
148 extern void
149 XkbcFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll);
150
151 extern void
152 XkbcFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll);
153
154 extern void
155 XkbcFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll);
156
157 extern void
158 XkbcFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap);
159
160 extern int
161 XkbcAllocGeomProps(XkbGeometryPtr geom, int nProps);
162
163 extern int
164 XkbcAllocGeomColors(XkbGeometryPtr geom, int nColors);
165
166 extern int
167 XkbcAllocGeomKeyAliases(XkbGeometryPtr geom, int nKeyAliases);
168
169 extern int
170 XkbcAllocGeomShapes(XkbGeometryPtr geom, int nShapes);
171
172 extern int
173 XkbcAllocGeomSections(XkbGeometryPtr geom, int nSections);
174
175 extern int
176 XkbcAllocGeomOverlays(XkbSectionPtr section, int nOverlays);
177
178 extern int
179 XkbcAllocGeomOverlayRows(XkbOverlayPtr overlay, int nRows);
180
181 extern int
182 XkbcAllocGeomOverlayKeys(XkbOverlayRowPtr row, int nKeys);
183
184 extern int
185 XkbcAllocGeomDoodads(XkbGeometryPtr geom, int nDoodads);
186
187 extern int
188 XkbcAllocGeomSectionDoodads(XkbSectionPtr section, int nDoodads);
189
190 extern int
191 XkbcAllocGeomOutlines(XkbShapePtr shape, int nOL);
192
193 extern int
194 XkbcAllocGeomRows(XkbSectionPtr section, int nRows);
195
196 extern int
197 XkbcAllocGeomPoints(XkbOutlinePtr ol, int nPts);
198
199 extern int
200 XkbcAllocGeomKeys(XkbRowPtr row, int nKeys);
201
202 extern int
203 XkbcAllocGeometry(XkbcDescPtr xkb, XkbGeometrySizesPtr sizes);
204
205 extern XkbPropertyPtr
206 XkbcAddGeomProperty(XkbGeometryPtr geom, char *name, char *value);
207
208 extern XkbKeyAliasPtr
209 XkbcAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr);
210
211 extern XkbColorPtr
212 XkbcAddGeomColor(XkbGeometryPtr geom, char *spec, unsigned int pixel);
213
214 extern XkbOutlinePtr
215 XkbcAddGeomOutline(XkbShapePtr shape, int sz_points);
216
217 extern XkbShapePtr
218 XkbcAddGeomShape(XkbGeometryPtr geom, Atom name, int sz_outlines);
219
220 extern XkbKeyPtr
221 XkbcAddGeomKey(XkbRowPtr row);
222
223 extern XkbRowPtr
224 XkbcAddGeomRow(XkbSectionPtr section, int sz_keys);
225
226 extern XkbSectionPtr
227 XkbcAddGeomSection(XkbGeometryPtr geom, Atom name,
228                    int sz_rows, int sz_doodads, int sz_over);
229
230 extern XkbDoodadPtr
231 XkbcAddGeomDoodad(XkbGeometryPtr geom, XkbSectionPtr section, Atom name);
232
233 extern XkbOverlayKeyPtr
234 XkbcAddGeomOverlayKey(XkbOverlayPtr overlay, XkbOverlayRowPtr row,
235                       char *over, char *under);
236
237 extern XkbOverlayRowPtr
238 XkbcAddGeomOverlayRow(XkbOverlayPtr overlay, int row_under, int sz_keys);
239
240 extern XkbOverlayPtr
241 XkbcAddGeomOverlay(XkbSectionPtr section, Atom name, int sz_rows);
242
243 extern void
244 XkbcInitAtoms(void);
245
246 extern char *
247 XkbcAtomGetString(Atom atom);
248
249 extern Atom
250 XkbcInternAtom(char *name, Bool onlyIfExists);
251
252 extern char *
253 XkbcAtomText(Atom atm);
254
255 extern char *
256 XkbcVModIndexText(XkbcDescPtr xkb, unsigned ndx);
257
258 extern char *
259 XkbcVModMaskText(XkbcDescPtr xkb, unsigned modMask, unsigned mask);
260
261 extern char *
262 XkbcModIndexText(unsigned ndx);
263
264 extern char *
265 XkbcModMaskText(unsigned mask, Bool cFormat);
266
267 extern char *
268 XkbcConfigText(unsigned config);
269
270 extern char *
271 XkbcGeomFPText(int val);
272
273 extern char *
274 XkbcActionTypeText(unsigned type);
275
276 extern char *
277 XkbcKeysymText(KeySym sym);
278
279 extern char *
280 XkbcKeyNameText(char *name);
281
282 extern char *
283 XkbcSIMatchText(unsigned type);
284
285 extern Bool
286 XkbcComputeShapeBounds(XkbShapePtr shape);
287
288 extern Bool
289 XkbcComputeShapeTop(XkbShapePtr shape, XkbBoundsPtr bounds);
290
291 extern Bool
292 XkbcComputeRowBounds(XkbGeometryPtr geom, XkbSectionPtr section, XkbRowPtr row);
293
294 extern Bool
295 XkbcComputeSectionBounds(XkbGeometryPtr geom, XkbSectionPtr section);
296
297 extern int
298 XkbcInitCanonicalKeyTypes(XkbcDescPtr xkb, unsigned which, int keypadVMod);
299
300 extern Bool
301 XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask,
302                       unsigned *mask_rtrn);
303
304 extern Bool
305 XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
306                         unsigned char *map_rtrn);
307
308 _XFUNCPROTOEND
309
310 #endif /* _XKBCOMMON_H_ */