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 XkbcCompileKeymapFromRules(const char *rules, XkbRF_VarDefsPtr defs);
73 XkbcCompileKeymapFromComponents(XkbComponentNamesPtr ktcsg);
76 XkbcKeysymToString(KeySym ks);
79 XkbcStringToKeysym(const char *s);
82 XkbcAllocCompatMap(XkbcDescPtr xkb, unsigned which, unsigned nSI);
85 XkbcFreeCompatMap(XkbcDescPtr xkb, unsigned which, Bool freeMap);
88 XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases);
91 XkbcFreeNames(XkbcDescPtr xkb, unsigned which, Bool freeMap);
94 XkbcAllocControls(XkbcDescPtr xkb, unsigned which);
97 XkbcFreeControls(XkbcDescPtr xkb, unsigned which, Bool freeMap);
100 XkbcAllocIndicatorMaps(XkbcDescPtr xkb);
103 XkbcFreeIndicatorMaps(XkbcDescPtr xkb);
106 XkbcAllocKeyboard(void);
109 XkbcFreeKeyboard(XkbcDescPtr xkb, unsigned which, Bool freeAll);
112 XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes);
115 XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions);
118 XkbcCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into);
121 XkbcCopyKeyTypes(XkbKeyTypePtr from, XkbKeyTypePtr into, int num_types);
124 XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
125 Bool want_preserve, int new_num_lvls);
128 XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed);
131 XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
132 XkbChangesPtr changes);
135 XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed);
138 XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
141 XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
144 XkbcFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll);
147 XkbcFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll);
150 XkbcFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll);
153 XkbcFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll);
156 XkbcFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll);
159 XkbcFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll);
162 XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count,
166 XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
170 XkbcFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll);
173 XkbcFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll);
176 XkbcFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll);
179 XkbcFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll);
182 XkbcFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll);
185 XkbcFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap);
188 XkbcAllocGeomProps(XkbGeometryPtr geom, int nProps);
191 XkbcAllocGeomColors(XkbGeometryPtr geom, int nColors);
194 XkbcAllocGeomKeyAliases(XkbGeometryPtr geom, int nKeyAliases);
197 XkbcAllocGeomShapes(XkbGeometryPtr geom, int nShapes);
200 XkbcAllocGeomSections(XkbGeometryPtr geom, int nSections);
203 XkbcAllocGeomOverlays(XkbSectionPtr section, int nOverlays);
206 XkbcAllocGeomOverlayRows(XkbOverlayPtr overlay, int nRows);
209 XkbcAllocGeomOverlayKeys(XkbOverlayRowPtr row, int nKeys);
212 XkbcAllocGeomDoodads(XkbGeometryPtr geom, int nDoodads);
215 XkbcAllocGeomSectionDoodads(XkbSectionPtr section, int nDoodads);
218 XkbcAllocGeomOutlines(XkbShapePtr shape, int nOL);
221 XkbcAllocGeomRows(XkbSectionPtr section, int nRows);
224 XkbcAllocGeomPoints(XkbOutlinePtr ol, int nPts);
227 XkbcAllocGeomKeys(XkbRowPtr row, int nKeys);
230 XkbcAllocGeometry(XkbcDescPtr xkb, XkbGeometrySizesPtr sizes);
232 extern XkbPropertyPtr
233 XkbcAddGeomProperty(XkbGeometryPtr geom, char *name, char *value);
235 extern XkbKeyAliasPtr
236 XkbcAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr);
239 XkbcAddGeomColor(XkbGeometryPtr geom, char *spec, unsigned int pixel);
242 XkbcAddGeomOutline(XkbShapePtr shape, int sz_points);
245 XkbcAddGeomShape(XkbGeometryPtr geom, Atom name, int sz_outlines);
248 XkbcAddGeomKey(XkbRowPtr row);
251 XkbcAddGeomRow(XkbSectionPtr section, int sz_keys);
254 XkbcAddGeomSection(XkbGeometryPtr geom, Atom name,
255 int sz_rows, int sz_doodads, int sz_over);
258 XkbcAddGeomDoodad(XkbGeometryPtr geom, XkbSectionPtr section, Atom name);
260 extern XkbOverlayKeyPtr
261 XkbcAddGeomOverlayKey(XkbOverlayPtr overlay, XkbOverlayRowPtr row,
262 char *over, char *under);
264 extern XkbOverlayRowPtr
265 XkbcAddGeomOverlayRow(XkbOverlayPtr overlay, int row_under, int sz_keys);
268 XkbcAddGeomOverlay(XkbSectionPtr section, Atom name, int sz_rows);
274 XkbcAtomGetString(Atom atom);
277 XkbcInternAtom(char *name, Bool onlyIfExists);
280 XkbcAtomText(Atom atm);
283 XkbcVModIndexText(XkbcDescPtr xkb, unsigned ndx);
286 XkbcVModMaskText(XkbcDescPtr xkb, unsigned modMask, unsigned mask);
289 XkbcModIndexText(unsigned ndx);
292 XkbcModMaskText(unsigned mask, Bool cFormat);
295 XkbcConfigText(unsigned config);
298 XkbcGeomFPText(int val);
301 XkbcActionTypeText(unsigned type);
304 XkbcKeysymText(KeySym sym);
307 XkbcKeyNameText(char *name);
310 XkbcSIMatchText(unsigned type);
313 XkbcComputeShapeBounds(XkbShapePtr shape);
316 XkbcComputeShapeTop(XkbShapePtr shape, XkbBoundsPtr bounds);
319 XkbcComputeRowBounds(XkbGeometryPtr geom, XkbSectionPtr section, XkbRowPtr row);
322 XkbcComputeSectionBounds(XkbGeometryPtr geom, XkbSectionPtr section);
325 XkbcRF_GetComponents(XkbRF_RulesPtr rules, XkbRF_VarDefsPtr defs,
326 XkbComponentNamesPtr names);
329 XkbcRF_AddRule(XkbRF_RulesPtr rules);
331 extern XkbRF_GroupPtr
332 XkbcRF_AddGroup(XkbRF_RulesPtr rules);
335 XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
338 XkbcRF_LoadRulesByName(char *base, char *locale, XkbRF_RulesPtr rules);
340 extern XkbRF_VarDescPtr
341 XkbcRF_AddVarDesc(XkbRF_DescribeVarsPtr vars);
343 extern XkbRF_VarDescPtr
344 XkbcRF_AddVarDescCopy(XkbRF_DescribeVarsPtr vars, XkbRF_VarDescPtr from);
346 extern XkbRF_DescribeVarsPtr
347 XkbcRF_AddVarToDescribe(XkbRF_RulesPtr rules, char *name);
350 XkbcRF_LoadDescriptions(FILE *file, XkbRF_RulesPtr rules);
353 XkbcRF_LoadDescriptionsByName(char *base, char *locale, XkbRF_RulesPtr rules);
355 extern XkbRF_RulesPtr
356 XkbcRF_Load(char *base, char *locale, Bool wantDesc, Bool wantRules);
358 extern XkbRF_RulesPtr
359 XkbcRF_Create(int szRules, int szExtra);
362 XkbcRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
365 XkbcInitCanonicalKeyTypes(XkbcDescPtr xkb, unsigned which, int keypadVMod);
368 XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask,
369 unsigned *mask_rtrn);
372 XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
373 unsigned char *map_rtrn);
376 XkbcEnsureSafeMapName(char *name);
379 _XkbcKSCheckCase(KeySym sym);
383 #endif /* _XKBCOMMON_H_ */