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 /* Action structures used in the server */
40 typedef struct _XkbcModAction {
44 unsigned char real_mods;
48 typedef struct _XkbcISOAction {
52 unsigned char real_mods;
53 /* FIXME: Make this an int. */
59 typedef struct _XkbcPtrAction {
66 typedef struct _XkbcCtrlsAction {
72 typedef struct _XkbcRedirectKeyAction {
74 unsigned char new_key;
75 unsigned char mods_mask;
77 unsigned int vmods_mask;
79 } XkbcRedirectKeyAction;
81 typedef union _XkbcAction {
88 XkbPtrDfltAction dflt;
89 XkbSwitchScreenAction screen;
90 XkbcCtrlsAction ctrls;
92 XkbcRedirectKeyAction redirect;
93 XkbDeviceBtnAction devbtn;
94 XkbDeviceValuatorAction devval;
98 typedef struct _XkbcServerMapRec {
99 unsigned short num_acts;
100 unsigned short size_acts;
103 XkbBehavior * behaviors;
104 unsigned short * key_acts;
105 #if defined(__cplusplus) || defined(c_plusplus)
106 /* explicit is a C++ reserved word */
107 unsigned char * c_explicit;
109 unsigned char * explicit;
111 unsigned char vmods[XkbNumVirtualMods];
112 unsigned short * vmodmap;
113 } XkbcServerMapRec, *XkbcServerMapPtr;
115 /* Common keyboard description structure */
116 typedef struct _XkbcDesc {
117 unsigned int defined;
118 unsigned short flags;
119 unsigned short device_spec;
120 KeyCode min_key_code;
121 KeyCode max_key_code;
123 XkbControlsPtr ctrls;
124 XkbcServerMapPtr server;
126 XkbIndicatorPtr indicators;
128 XkbCompatMapPtr compat;
130 } XkbcDescRec, *XkbcDescPtr;
132 #define XkbcKSIsLower(k) (_XkbcKSCheckCase(k) & _XkbcKSLower)
133 #define XkbcKSIsUpper(k) (_XkbcKSCheckCase(k) & _XkbcKSUpper)
138 XkbcCompileKeymapFromRules(const char *rules, XkbRF_VarDefsPtr defs);
141 XkbcCompileKeymapFromComponents(XkbComponentNamesPtr ktcsg);
144 XkbcKeysymToString(KeySym ks);
147 XkbcStringToKeysym(const char *s);
150 XkbcAllocCompatMap(XkbcDescPtr xkb, unsigned which, unsigned nSI);
153 XkbcFreeCompatMap(XkbcDescPtr xkb, unsigned which, Bool freeMap);
156 XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases);
159 XkbcFreeNames(XkbcDescPtr xkb, unsigned which, Bool freeMap);
162 XkbcAllocControls(XkbcDescPtr xkb, unsigned which);
165 XkbcFreeControls(XkbcDescPtr xkb, unsigned which, Bool freeMap);
168 XkbcAllocIndicatorMaps(XkbcDescPtr xkb);
171 XkbcFreeIndicatorMaps(XkbcDescPtr xkb);
174 XkbcAllocKeyboard(void);
177 XkbcFreeKeyboard(XkbcDescPtr xkb, unsigned which, Bool freeAll);
180 XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes);
183 XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions);
186 XkbcCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into);
189 XkbcCopyKeyTypes(XkbKeyTypePtr from, XkbKeyTypePtr into, int num_types);
192 XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
193 Bool want_preserve, int new_num_lvls);
196 XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed);
199 XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
200 XkbChangesPtr changes);
203 XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed);
206 XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
209 XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
212 XkbcFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll);
215 XkbcFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll);
218 XkbcFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll);
221 XkbcFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll);
224 XkbcFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll);
227 XkbcFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll);
230 XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count,
234 XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
238 XkbcFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll);
241 XkbcFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll);
244 XkbcFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll);
247 XkbcFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll);
250 XkbcFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll);
253 XkbcFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap);
256 XkbcAllocGeomProps(XkbGeometryPtr geom, int nProps);
259 XkbcAllocGeomColors(XkbGeometryPtr geom, int nColors);
262 XkbcAllocGeomKeyAliases(XkbGeometryPtr geom, int nKeyAliases);
265 XkbcAllocGeomShapes(XkbGeometryPtr geom, int nShapes);
268 XkbcAllocGeomSections(XkbGeometryPtr geom, int nSections);
271 XkbcAllocGeomOverlays(XkbSectionPtr section, int nOverlays);
274 XkbcAllocGeomOverlayRows(XkbOverlayPtr overlay, int nRows);
277 XkbcAllocGeomOverlayKeys(XkbOverlayRowPtr row, int nKeys);
280 XkbcAllocGeomDoodads(XkbGeometryPtr geom, int nDoodads);
283 XkbcAllocGeomSectionDoodads(XkbSectionPtr section, int nDoodads);
286 XkbcAllocGeomOutlines(XkbShapePtr shape, int nOL);
289 XkbcAllocGeomRows(XkbSectionPtr section, int nRows);
292 XkbcAllocGeomPoints(XkbOutlinePtr ol, int nPts);
295 XkbcAllocGeomKeys(XkbRowPtr row, int nKeys);
298 XkbcAllocGeometry(XkbcDescPtr xkb, XkbGeometrySizesPtr sizes);
300 extern XkbPropertyPtr
301 XkbcAddGeomProperty(XkbGeometryPtr geom, char *name, char *value);
303 extern XkbKeyAliasPtr
304 XkbcAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr);
307 XkbcAddGeomColor(XkbGeometryPtr geom, char *spec, unsigned int pixel);
310 XkbcAddGeomOutline(XkbShapePtr shape, int sz_points);
313 XkbcAddGeomShape(XkbGeometryPtr geom, Atom name, int sz_outlines);
316 XkbcAddGeomKey(XkbRowPtr row);
319 XkbcAddGeomRow(XkbSectionPtr section, int sz_keys);
322 XkbcAddGeomSection(XkbGeometryPtr geom, Atom name,
323 int sz_rows, int sz_doodads, int sz_over);
326 XkbcAddGeomDoodad(XkbGeometryPtr geom, XkbSectionPtr section, Atom name);
328 extern XkbOverlayKeyPtr
329 XkbcAddGeomOverlayKey(XkbOverlayPtr overlay, XkbOverlayRowPtr row,
330 char *over, char *under);
332 extern XkbOverlayRowPtr
333 XkbcAddGeomOverlayRow(XkbOverlayPtr overlay, int row_under, int sz_keys);
336 XkbcAddGeomOverlay(XkbSectionPtr section, Atom name, int sz_rows);
342 XkbcAtomGetString(Atom atom);
345 XkbcInternAtom(char *name, Bool onlyIfExists);
348 XkbcAtomText(Atom atm);
351 XkbcVModIndexText(XkbcDescPtr xkb, unsigned ndx);
354 XkbcVModMaskText(XkbcDescPtr xkb, unsigned modMask, unsigned mask);
357 XkbcModIndexText(unsigned ndx);
360 XkbcModMaskText(unsigned mask, Bool cFormat);
363 XkbcConfigText(unsigned config);
366 XkbcGeomFPText(int val);
369 XkbcActionTypeText(unsigned type);
372 XkbcKeysymText(KeySym sym);
375 XkbcKeyNameText(char *name);
378 XkbcSIMatchText(unsigned type);
381 XkbcComputeShapeBounds(XkbShapePtr shape);
384 XkbcComputeShapeTop(XkbShapePtr shape, XkbBoundsPtr bounds);
387 XkbcComputeRowBounds(XkbGeometryPtr geom, XkbSectionPtr section, XkbRowPtr row);
390 XkbcComputeSectionBounds(XkbGeometryPtr geom, XkbSectionPtr section);
393 XkbcRF_GetComponents(XkbRF_RulesPtr rules, XkbRF_VarDefsPtr defs,
394 XkbComponentNamesPtr names);
397 XkbcRF_AddRule(XkbRF_RulesPtr rules);
399 extern XkbRF_GroupPtr
400 XkbcRF_AddGroup(XkbRF_RulesPtr rules);
403 XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
406 XkbcRF_LoadRulesByName(char *base, char *locale, XkbRF_RulesPtr rules);
408 extern XkbRF_VarDescPtr
409 XkbcRF_AddVarDesc(XkbRF_DescribeVarsPtr vars);
411 extern XkbRF_VarDescPtr
412 XkbcRF_AddVarDescCopy(XkbRF_DescribeVarsPtr vars, XkbRF_VarDescPtr from);
414 extern XkbRF_DescribeVarsPtr
415 XkbcRF_AddVarToDescribe(XkbRF_RulesPtr rules, char *name);
418 XkbcRF_LoadDescriptions(FILE *file, XkbRF_RulesPtr rules);
421 XkbcRF_LoadDescriptionsByName(char *base, char *locale, XkbRF_RulesPtr rules);
423 extern XkbRF_RulesPtr
424 XkbcRF_Load(char *base, char *locale, Bool wantDesc, Bool wantRules);
426 extern XkbRF_RulesPtr
427 XkbcRF_Create(int szRules, int szExtra);
430 XkbcRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
433 XkbcInitCanonicalKeyTypes(XkbcDescPtr xkb, unsigned which, int keypadVMod);
436 XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask,
437 unsigned *mask_rtrn);
440 XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
441 unsigned char *map_rtrn);
444 XkbcEnsureSafeMapName(char *name);
447 _XkbcKSCheckCase(KeySym sym);
451 #endif /* _XKBCOMMON_H_ */