2 Copyright 1985, 1987, 1990, 1998 The Open Group
3 Copyright 2008 Dan Nicholson
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:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
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.
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.
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>
39 /* Common keyboard description structure */
40 typedef struct _XkbcDesc {
43 unsigned short device_spec;
48 XkbServerMapPtr server;
50 XkbIndicatorPtr indicators;
52 XkbCompatMapPtr compat;
54 } XkbcDescRec, *XkbcDescPtr;
56 #define _XkbcKSLower (1 << 0)
57 #define _XkbcKSUpper (1 << 1)
59 #define XkbcKSIsLower(k) (_XkbcKSCheckCase(k) & _XkbcKSLower)
60 #define XkbcKSIsUpper(k) (_XkbcKSCheckCase(k) & _XkbcKSUpper)
61 #define XkbcKSIsKeypad(k) \
62 (((k) >= XK_KP_Space) && ((k) <= XK_KP_Equal))
63 #define XkbcKSIsDeadKey(k) \
64 (((k) >= XK_dead_grave) && ((k) <= XK_dead_semivoiced_sound))
69 XkbcCompileKeymapFromRules(const char *rules, XkbRF_VarDefsPtr defs);
72 XkbcCompileKeymapFromComponents(XkbComponentNamesPtr ktcsg);
75 XkbcKeysymToString(KeySym ks);
78 XkbcStringToKeysym(const char *s);
81 XkbcAllocCompatMap(XkbcDescPtr xkb, unsigned which, unsigned nSI);
84 XkbcFreeCompatMap(XkbcDescPtr xkb, unsigned which, Bool freeMap);
87 XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases);
90 XkbcFreeNames(XkbcDescPtr xkb, unsigned which, Bool freeMap);
93 XkbcAllocControls(XkbcDescPtr xkb, unsigned which);
96 XkbcFreeControls(XkbcDescPtr xkb, unsigned which, Bool freeMap);
99 XkbcAllocIndicatorMaps(XkbcDescPtr xkb);
102 XkbcFreeIndicatorMaps(XkbcDescPtr xkb);
105 XkbcAllocKeyboard(void);
108 XkbcFreeKeyboard(XkbcDescPtr xkb, unsigned which, Bool freeAll);
111 XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes);
114 XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions);
117 XkbcCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into);
120 XkbcCopyKeyTypes(XkbKeyTypePtr from, XkbKeyTypePtr into, int num_types);
123 XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
124 Bool want_preserve, int new_num_lvls);
127 XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed);
130 XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
131 XkbChangesPtr changes);
134 XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed);
137 XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
140 XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
143 XkbcFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll);
146 XkbcFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll);
149 XkbcFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll);
152 XkbcFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll);
155 XkbcFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll);
158 XkbcFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll);
161 XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count,
165 XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
169 XkbcFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll);
172 XkbcFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll);
175 XkbcFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll);
178 XkbcFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll);
181 XkbcFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll);
184 XkbcFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap);
187 XkbcAllocGeomProps(XkbGeometryPtr geom, int nProps);
190 XkbcAllocGeomColors(XkbGeometryPtr geom, int nColors);
193 XkbcAllocGeomKeyAliases(XkbGeometryPtr geom, int nKeyAliases);
196 XkbcAllocGeomShapes(XkbGeometryPtr geom, int nShapes);
199 XkbcAllocGeomSections(XkbGeometryPtr geom, int nSections);
202 XkbcAllocGeomOverlays(XkbSectionPtr section, int nOverlays);
205 XkbcAllocGeomOverlayRows(XkbOverlayPtr overlay, int nRows);
208 XkbcAllocGeomOverlayKeys(XkbOverlayRowPtr row, int nKeys);
211 XkbcAllocGeomDoodads(XkbGeometryPtr geom, int nDoodads);
214 XkbcAllocGeomSectionDoodads(XkbSectionPtr section, int nDoodads);
217 XkbcAllocGeomOutlines(XkbShapePtr shape, int nOL);
220 XkbcAllocGeomRows(XkbSectionPtr section, int nRows);
223 XkbcAllocGeomPoints(XkbOutlinePtr ol, int nPts);
226 XkbcAllocGeomKeys(XkbRowPtr row, int nKeys);
229 XkbcAllocGeometry(XkbcDescPtr xkb, XkbGeometrySizesPtr sizes);
231 extern XkbPropertyPtr
232 XkbcAddGeomProperty(XkbGeometryPtr geom, char *name, char *value);
234 extern XkbKeyAliasPtr
235 XkbcAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr);
238 XkbcAddGeomColor(XkbGeometryPtr geom, char *spec, unsigned int pixel);
241 XkbcAddGeomOutline(XkbShapePtr shape, int sz_points);
244 XkbcAddGeomShape(XkbGeometryPtr geom, Atom name, int sz_outlines);
247 XkbcAddGeomKey(XkbRowPtr row);
250 XkbcAddGeomRow(XkbSectionPtr section, int sz_keys);
253 XkbcAddGeomSection(XkbGeometryPtr geom, Atom name,
254 int sz_rows, int sz_doodads, int sz_over);
257 XkbcAddGeomDoodad(XkbGeometryPtr geom, XkbSectionPtr section, Atom name);
259 extern XkbOverlayKeyPtr
260 XkbcAddGeomOverlayKey(XkbOverlayPtr overlay, XkbOverlayRowPtr row,
261 char *over, char *under);
263 extern XkbOverlayRowPtr
264 XkbcAddGeomOverlayRow(XkbOverlayPtr overlay, int row_under, int sz_keys);
267 XkbcAddGeomOverlay(XkbSectionPtr section, Atom name, int sz_rows);
273 XkbcAtomGetString(Atom atom);
276 XkbcInternAtom(char *name, Bool onlyIfExists);
279 XkbcAtomText(Atom atm);
282 XkbcVModIndexText(XkbcDescPtr xkb, unsigned ndx);
285 XkbcVModMaskText(XkbcDescPtr xkb, unsigned modMask, unsigned mask);
288 XkbcModIndexText(unsigned ndx);
291 XkbcModMaskText(unsigned mask, Bool cFormat);
294 XkbcConfigText(unsigned config);
297 XkbcGeomFPText(int val);
300 XkbcActionTypeText(unsigned type);
303 XkbcKeysymText(KeySym sym);
306 XkbcKeyNameText(char *name);
309 XkbcSIMatchText(unsigned type);
312 XkbcComputeShapeBounds(XkbShapePtr shape);
315 XkbcComputeShapeTop(XkbShapePtr shape, XkbBoundsPtr bounds);
318 XkbcComputeRowBounds(XkbGeometryPtr geom, XkbSectionPtr section, XkbRowPtr row);
321 XkbcComputeSectionBounds(XkbGeometryPtr geom, XkbSectionPtr section);
324 XkbcRF_GetComponents(XkbRF_RulesPtr rules, XkbRF_VarDefsPtr defs,
325 XkbComponentNamesPtr names);
328 XkbcRF_AddRule(XkbRF_RulesPtr rules);
330 extern XkbRF_GroupPtr
331 XkbcRF_AddGroup(XkbRF_RulesPtr rules);
334 XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
337 XkbcRF_LoadRulesByName(char *base, char *locale, XkbRF_RulesPtr rules);
339 extern XkbRF_VarDescPtr
340 XkbcRF_AddVarDesc(XkbRF_DescribeVarsPtr vars);
342 extern XkbRF_VarDescPtr
343 XkbcRF_AddVarDescCopy(XkbRF_DescribeVarsPtr vars, XkbRF_VarDescPtr from);
345 extern XkbRF_DescribeVarsPtr
346 XkbcRF_AddVarToDescribe(XkbRF_RulesPtr rules, char *name);
349 XkbcRF_LoadDescriptions(FILE *file, XkbRF_RulesPtr rules);
352 XkbcRF_LoadDescriptionsByName(char *base, char *locale, XkbRF_RulesPtr rules);
354 extern XkbRF_RulesPtr
355 XkbcRF_Load(char *base, char *locale, Bool wantDesc, Bool wantRules);
357 extern XkbRF_RulesPtr
358 XkbcRF_Create(int szRules, int szExtra);
361 XkbcRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
364 XkbcInitCanonicalKeyTypes(XkbcDescPtr xkb, unsigned which, int keypadVMod);
367 XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask,
368 unsigned *mask_rtrn);
371 XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
372 unsigned char *map_rtrn);
375 XkbcEnsureSafeMapName(char *name);
378 _XkbcKSCheckCase(KeySym sym);
382 #endif /* _XKBCOMMON_H_ */