Generate keyboard description from components
[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/keysym.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 _XkbcKSLower (1 << 0)
56 #define _XkbcKSUpper (1 << 1)
57
58 #define XkbcKSIsLower(k) (_XkbcKSCheckCase(k) & _XkbcKSLower)
59 #define XkbcKSIsUpper(k) (_XkbcKSCheckCase(k) & _XkbcKSUpper)
60 #define XkbcKSIsKeypad(k) \
61     (((k) >= XK_KP_Space) && ((k) <= XK_KP_Equal))
62 #define XkbcKSIsDeadKey(k) \
63     (((k) >= XK_dead_grave) && ((k) <= XK_dead_semivoiced_sound))
64
65 _XFUNCPROTOBEGIN
66
67 extern XkbcDescPtr
68 XkbcCompileKeymap(XkbComponentNamesPtr ktcsg);
69
70 extern char *
71 XkbcKeysymToString(KeySym ks);
72
73 extern KeySym
74 XkbcStringToKeysym(const char *s);
75
76 extern int
77 XkbcAllocCompatMap(XkbcDescPtr xkb, unsigned which, unsigned nSI);
78
79 extern void
80 XkbcFreeCompatMap(XkbcDescPtr xkb, unsigned which, Bool freeMap);
81
82 extern int
83 XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases);
84
85 extern void
86 XkbcFreeNames(XkbcDescPtr xkb, unsigned which, Bool freeMap);
87
88 extern int
89 XkbcAllocControls(XkbcDescPtr xkb, unsigned which);
90
91 extern void
92 XkbcFreeControls(XkbcDescPtr xkb, unsigned which, Bool freeMap);
93
94 extern int
95 XkbcAllocIndicatorMaps(XkbcDescPtr xkb);
96
97 extern void
98 XkbcFreeIndicatorMaps(XkbcDescPtr xkb);
99
100 extern XkbcDescRec *
101 XkbcAllocKeyboard(void);
102
103 extern void
104 XkbcFreeKeyboard(XkbcDescPtr xkb, unsigned which, Bool freeAll);
105
106 extern int
107 XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes);
108
109 extern int
110 XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions);
111
112 extern int
113 XkbcCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into);
114
115 extern int
116 XkbcCopyKeyTypes(XkbKeyTypePtr from, XkbKeyTypePtr into, int num_types);
117
118 extern int
119 XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
120                   Bool want_preserve, int new_num_lvls);
121
122 extern KeySym *
123 XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed);
124
125 extern int
126 XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
127                        XkbChangesPtr changes);
128
129 extern XkbAction *
130 XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed);
131
132 extern void
133 XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
134
135 extern void
136 XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
137
138 extern void
139 XkbcFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll);
140
141 extern void
142 XkbcFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll);
143
144 extern void
145 XkbcFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll);
146
147 extern void
148 XkbcFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll);
149
150 extern void
151 XkbcFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll);
152
153 extern void
154 XkbcFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll);
155
156 extern void
157 XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count,
158                         Bool freeAll);
159
160 extern void
161 XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
162                         Bool freeAll);
163
164 extern void
165 XkbcFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll);
166
167 extern void
168 XkbcFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll);
169
170 extern void
171 XkbcFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll);
172
173 extern void
174 XkbcFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll);
175
176 extern void
177 XkbcFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll);
178
179 extern void
180 XkbcFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap);
181
182 extern int
183 XkbcAllocGeomProps(XkbGeometryPtr geom, int nProps);
184
185 extern int
186 XkbcAllocGeomColors(XkbGeometryPtr geom, int nColors);
187
188 extern int
189 XkbcAllocGeomKeyAliases(XkbGeometryPtr geom, int nKeyAliases);
190
191 extern int
192 XkbcAllocGeomShapes(XkbGeometryPtr geom, int nShapes);
193
194 extern int
195 XkbcAllocGeomSections(XkbGeometryPtr geom, int nSections);
196
197 extern int
198 XkbcAllocGeomOverlays(XkbSectionPtr section, int nOverlays);
199
200 extern int
201 XkbcAllocGeomOverlayRows(XkbOverlayPtr overlay, int nRows);
202
203 extern int
204 XkbcAllocGeomOverlayKeys(XkbOverlayRowPtr row, int nKeys);
205
206 extern int
207 XkbcAllocGeomDoodads(XkbGeometryPtr geom, int nDoodads);
208
209 extern int
210 XkbcAllocGeomSectionDoodads(XkbSectionPtr section, int nDoodads);
211
212 extern int
213 XkbcAllocGeomOutlines(XkbShapePtr shape, int nOL);
214
215 extern int
216 XkbcAllocGeomRows(XkbSectionPtr section, int nRows);
217
218 extern int
219 XkbcAllocGeomPoints(XkbOutlinePtr ol, int nPts);
220
221 extern int
222 XkbcAllocGeomKeys(XkbRowPtr row, int nKeys);
223
224 extern int
225 XkbcAllocGeometry(XkbcDescPtr xkb, XkbGeometrySizesPtr sizes);
226
227 extern XkbPropertyPtr
228 XkbcAddGeomProperty(XkbGeometryPtr geom, char *name, char *value);
229
230 extern XkbKeyAliasPtr
231 XkbcAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr);
232
233 extern XkbColorPtr
234 XkbcAddGeomColor(XkbGeometryPtr geom, char *spec, unsigned int pixel);
235
236 extern XkbOutlinePtr
237 XkbcAddGeomOutline(XkbShapePtr shape, int sz_points);
238
239 extern XkbShapePtr
240 XkbcAddGeomShape(XkbGeometryPtr geom, Atom name, int sz_outlines);
241
242 extern XkbKeyPtr
243 XkbcAddGeomKey(XkbRowPtr row);
244
245 extern XkbRowPtr
246 XkbcAddGeomRow(XkbSectionPtr section, int sz_keys);
247
248 extern XkbSectionPtr
249 XkbcAddGeomSection(XkbGeometryPtr geom, Atom name,
250                    int sz_rows, int sz_doodads, int sz_over);
251
252 extern XkbDoodadPtr
253 XkbcAddGeomDoodad(XkbGeometryPtr geom, XkbSectionPtr section, Atom name);
254
255 extern XkbOverlayKeyPtr
256 XkbcAddGeomOverlayKey(XkbOverlayPtr overlay, XkbOverlayRowPtr row,
257                       char *over, char *under);
258
259 extern XkbOverlayRowPtr
260 XkbcAddGeomOverlayRow(XkbOverlayPtr overlay, int row_under, int sz_keys);
261
262 extern XkbOverlayPtr
263 XkbcAddGeomOverlay(XkbSectionPtr section, Atom name, int sz_rows);
264
265 extern void
266 XkbcInitAtoms(void);
267
268 extern char *
269 XkbcAtomGetString(Atom atom);
270
271 extern Atom
272 XkbcInternAtom(char *name, Bool onlyIfExists);
273
274 extern char *
275 XkbcAtomText(Atom atm);
276
277 extern char *
278 XkbcVModIndexText(XkbcDescPtr xkb, unsigned ndx);
279
280 extern char *
281 XkbcVModMaskText(XkbcDescPtr xkb, unsigned modMask, unsigned mask);
282
283 extern char *
284 XkbcModIndexText(unsigned ndx);
285
286 extern char *
287 XkbcModMaskText(unsigned mask, Bool cFormat);
288
289 extern char *
290 XkbcConfigText(unsigned config);
291
292 extern char *
293 XkbcGeomFPText(int val);
294
295 extern char *
296 XkbcActionTypeText(unsigned type);
297
298 extern char *
299 XkbcKeysymText(KeySym sym);
300
301 extern char *
302 XkbcKeyNameText(char *name);
303
304 extern char *
305 XkbcSIMatchText(unsigned type);
306
307 extern Bool
308 XkbcComputeShapeBounds(XkbShapePtr shape);
309
310 extern Bool
311 XkbcComputeShapeTop(XkbShapePtr shape, XkbBoundsPtr bounds);
312
313 extern Bool
314 XkbcComputeRowBounds(XkbGeometryPtr geom, XkbSectionPtr section, XkbRowPtr row);
315
316 extern Bool
317 XkbcComputeSectionBounds(XkbGeometryPtr geom, XkbSectionPtr section);
318
319 extern int
320 XkbcInitCanonicalKeyTypes(XkbcDescPtr xkb, unsigned which, int keypadVMod);
321
322 extern Bool
323 XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask,
324                       unsigned *mask_rtrn);
325
326 extern Bool
327 XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
328                         unsigned char *map_rtrn);
329
330 extern void
331 XkbcEnsureSafeMapName(char *name);
332
333 extern unsigned
334 _XkbcKSCheckCase(KeySym  sym);
335
336 _XFUNCPROTOEND
337
338 #endif /* _XKBCOMMON_H_ */