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/keysym.h>
36 #include <X11/extensions/XKBstrcommon.h>
37 #include <X11/extensions/XKBgeomcommon.h>
38 #include <X11/extensions/XKBrulescommon.h>
40 /* Common keyboard description structure */
41 typedef struct _XkbcDesc {
44 unsigned short device_spec;
49 XkbServerMapPtr server;
51 XkbIndicatorPtr indicators;
53 XkbCompatMapPtr compat;
55 } XkbcDescRec, *XkbcDescPtr;
57 #define _XkbcKSLower (1 << 0)
58 #define _XkbcKSUpper (1 << 1)
60 #define XkbcKSIsLower(k) (_XkbcKSCheckCase(k) & _XkbcKSLower)
61 #define XkbcKSIsUpper(k) (_XkbcKSCheckCase(k) & _XkbcKSUpper)
62 #define XkbcKSIsKeypad(k) \
63 (((k) >= XK_KP_Space) && ((k) <= XK_KP_Equal))
64 #define XkbcKSIsDeadKey(k) \
65 (((k) >= XK_dead_grave) && ((k) <= XK_dead_semivoiced_sound))
70 XkbcCompileKeymap(XkbComponentNamesPtr ktcsg);
73 XkbcKeysymToString(KeySym ks);
76 XkbcStringToKeysym(const char *s);
79 XkbcAllocCompatMap(XkbcDescPtr xkb, unsigned which, unsigned nSI);
82 XkbcFreeCompatMap(XkbcDescPtr xkb, unsigned which, Bool freeMap);
85 XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases);
88 XkbcFreeNames(XkbcDescPtr xkb, unsigned which, Bool freeMap);
91 XkbcAllocControls(XkbcDescPtr xkb, unsigned which);
94 XkbcFreeControls(XkbcDescPtr xkb, unsigned which, Bool freeMap);
97 XkbcAllocIndicatorMaps(XkbcDescPtr xkb);
100 XkbcFreeIndicatorMaps(XkbcDescPtr xkb);
103 XkbcAllocKeyboard(void);
106 XkbcFreeKeyboard(XkbcDescPtr xkb, unsigned which, Bool freeAll);
109 XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes);
112 XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions);
115 XkbcCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into);
118 XkbcCopyKeyTypes(XkbKeyTypePtr from, XkbKeyTypePtr into, int num_types);
121 XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
122 Bool want_preserve, int new_num_lvls);
125 XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed);
128 XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
129 XkbChangesPtr changes);
132 XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed);
135 XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
138 XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
141 XkbcFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll);
144 XkbcFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll);
147 XkbcFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll);
150 XkbcFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll);
153 XkbcFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll);
156 XkbcFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll);
159 XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count,
163 XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
167 XkbcFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll);
170 XkbcFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll);
173 XkbcFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll);
176 XkbcFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll);
179 XkbcFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll);
182 XkbcFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap);
185 XkbcAllocGeomProps(XkbGeometryPtr geom, int nProps);
188 XkbcAllocGeomColors(XkbGeometryPtr geom, int nColors);
191 XkbcAllocGeomKeyAliases(XkbGeometryPtr geom, int nKeyAliases);
194 XkbcAllocGeomShapes(XkbGeometryPtr geom, int nShapes);
197 XkbcAllocGeomSections(XkbGeometryPtr geom, int nSections);
200 XkbcAllocGeomOverlays(XkbSectionPtr section, int nOverlays);
203 XkbcAllocGeomOverlayRows(XkbOverlayPtr overlay, int nRows);
206 XkbcAllocGeomOverlayKeys(XkbOverlayRowPtr row, int nKeys);
209 XkbcAllocGeomDoodads(XkbGeometryPtr geom, int nDoodads);
212 XkbcAllocGeomSectionDoodads(XkbSectionPtr section, int nDoodads);
215 XkbcAllocGeomOutlines(XkbShapePtr shape, int nOL);
218 XkbcAllocGeomRows(XkbSectionPtr section, int nRows);
221 XkbcAllocGeomPoints(XkbOutlinePtr ol, int nPts);
224 XkbcAllocGeomKeys(XkbRowPtr row, int nKeys);
227 XkbcAllocGeometry(XkbcDescPtr xkb, XkbGeometrySizesPtr sizes);
229 extern XkbPropertyPtr
230 XkbcAddGeomProperty(XkbGeometryPtr geom, char *name, char *value);
232 extern XkbKeyAliasPtr
233 XkbcAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr);
236 XkbcAddGeomColor(XkbGeometryPtr geom, char *spec, unsigned int pixel);
239 XkbcAddGeomOutline(XkbShapePtr shape, int sz_points);
242 XkbcAddGeomShape(XkbGeometryPtr geom, Atom name, int sz_outlines);
245 XkbcAddGeomKey(XkbRowPtr row);
248 XkbcAddGeomRow(XkbSectionPtr section, int sz_keys);
251 XkbcAddGeomSection(XkbGeometryPtr geom, Atom name,
252 int sz_rows, int sz_doodads, int sz_over);
255 XkbcAddGeomDoodad(XkbGeometryPtr geom, XkbSectionPtr section, Atom name);
257 extern XkbOverlayKeyPtr
258 XkbcAddGeomOverlayKey(XkbOverlayPtr overlay, XkbOverlayRowPtr row,
259 char *over, char *under);
261 extern XkbOverlayRowPtr
262 XkbcAddGeomOverlayRow(XkbOverlayPtr overlay, int row_under, int sz_keys);
265 XkbcAddGeomOverlay(XkbSectionPtr section, Atom name, int sz_rows);
271 XkbcAtomGetString(Atom atom);
274 XkbcInternAtom(char *name, Bool onlyIfExists);
277 XkbcAtomText(Atom atm);
280 XkbcVModIndexText(XkbcDescPtr xkb, unsigned ndx);
283 XkbcVModMaskText(XkbcDescPtr xkb, unsigned modMask, unsigned mask);
286 XkbcModIndexText(unsigned ndx);
289 XkbcModMaskText(unsigned mask, Bool cFormat);
292 XkbcConfigText(unsigned config);
295 XkbcGeomFPText(int val);
298 XkbcActionTypeText(unsigned type);
301 XkbcKeysymText(KeySym sym);
304 XkbcKeyNameText(char *name);
307 XkbcSIMatchText(unsigned type);
310 XkbcComputeShapeBounds(XkbShapePtr shape);
313 XkbcComputeShapeTop(XkbShapePtr shape, XkbBoundsPtr bounds);
316 XkbcComputeRowBounds(XkbGeometryPtr geom, XkbSectionPtr section, XkbRowPtr row);
319 XkbcComputeSectionBounds(XkbGeometryPtr geom, XkbSectionPtr section);
322 XkbcRF_GetComponents(XkbRF_RulesPtr rules, XkbRF_VarDefsPtr defs,
323 XkbComponentNamesPtr names);
326 XkbcRF_AddRule(XkbRF_RulesPtr rules);
328 extern XkbRF_GroupPtr
329 XkbcRF_AddGroup(XkbRF_RulesPtr rules);
332 XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
335 XkbcRF_LoadRulesByName(char *base, char *locale, XkbRF_RulesPtr rules);
337 extern XkbRF_VarDescPtr
338 XkbcRF_AddVarDesc(XkbRF_DescribeVarsPtr vars);
340 extern XkbRF_VarDescPtr
341 XkbcRF_AddVarDescCopy(XkbRF_DescribeVarsPtr vars, XkbRF_VarDescPtr from);
343 extern XkbRF_DescribeVarsPtr
344 XkbcRF_AddVarToDescribe(XkbRF_RulesPtr rules, char *name);
347 XkbcRF_LoadDescriptions(FILE *file, XkbRF_RulesPtr rules);
350 XkbcRF_LoadDescriptionsByName(char *base, char *locale, XkbRF_RulesPtr rules);
352 extern XkbRF_RulesPtr
353 XkbcRF_Load(char *base, char *locale, Bool wantDesc, Bool wantRules);
355 extern XkbRF_RulesPtr
356 XkbcRF_Create(int szRules, int szExtra);
359 XkbcRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
362 XkbcInitCanonicalKeyTypes(XkbcDescPtr xkb, unsigned which, int keypadVMod);
365 XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask,
366 unsigned *mask_rtrn);
369 XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
370 unsigned char *map_rtrn);
373 XkbcEnsureSafeMapName(char *name);
376 _XkbcKSCheckCase(KeySym sym);
380 #endif /* _XKBCOMMON_H_ */