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 _XkbcKSLower (1 << 0)
133 #define _XkbcKSUpper (1 << 1)
135 #define XkbcKSIsLower(k) (_XkbcKSCheckCase(k) & _XkbcKSLower)
136 #define XkbcKSIsUpper(k) (_XkbcKSCheckCase(k) & _XkbcKSUpper)
137 #define XkbcKSIsKeypad(k) \
138 (((k) >= XK_KP_Space) && ((k) <= XK_KP_Equal))
139 #define XkbcKSIsDeadKey(k) \
140 (((k) >= XK_dead_grave) && ((k) <= XK_dead_semivoiced_sound))
145 XkbcCompileKeymapFromRules(const char *rules, XkbRF_VarDefsPtr defs);
148 XkbcCompileKeymapFromComponents(XkbComponentNamesPtr ktcsg);
151 XkbcKeysymToString(KeySym ks);
154 XkbcStringToKeysym(const char *s);
157 XkbcAllocCompatMap(XkbcDescPtr xkb, unsigned which, unsigned nSI);
160 XkbcFreeCompatMap(XkbcDescPtr xkb, unsigned which, Bool freeMap);
163 XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases);
166 XkbcFreeNames(XkbcDescPtr xkb, unsigned which, Bool freeMap);
169 XkbcAllocControls(XkbcDescPtr xkb, unsigned which);
172 XkbcFreeControls(XkbcDescPtr xkb, unsigned which, Bool freeMap);
175 XkbcAllocIndicatorMaps(XkbcDescPtr xkb);
178 XkbcFreeIndicatorMaps(XkbcDescPtr xkb);
181 XkbcAllocKeyboard(void);
184 XkbcFreeKeyboard(XkbcDescPtr xkb, unsigned which, Bool freeAll);
187 XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes);
190 XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions);
193 XkbcCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into);
196 XkbcCopyKeyTypes(XkbKeyTypePtr from, XkbKeyTypePtr into, int num_types);
199 XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
200 Bool want_preserve, int new_num_lvls);
203 XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed);
206 XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
207 XkbChangesPtr changes);
210 XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed);
213 XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
216 XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
219 XkbcFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll);
222 XkbcFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll);
225 XkbcFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll);
228 XkbcFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll);
231 XkbcFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll);
234 XkbcFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll);
237 XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count,
241 XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
245 XkbcFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll);
248 XkbcFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll);
251 XkbcFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll);
254 XkbcFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll);
257 XkbcFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll);
260 XkbcFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap);
263 XkbcAllocGeomProps(XkbGeometryPtr geom, int nProps);
266 XkbcAllocGeomColors(XkbGeometryPtr geom, int nColors);
269 XkbcAllocGeomKeyAliases(XkbGeometryPtr geom, int nKeyAliases);
272 XkbcAllocGeomShapes(XkbGeometryPtr geom, int nShapes);
275 XkbcAllocGeomSections(XkbGeometryPtr geom, int nSections);
278 XkbcAllocGeomOverlays(XkbSectionPtr section, int nOverlays);
281 XkbcAllocGeomOverlayRows(XkbOverlayPtr overlay, int nRows);
284 XkbcAllocGeomOverlayKeys(XkbOverlayRowPtr row, int nKeys);
287 XkbcAllocGeomDoodads(XkbGeometryPtr geom, int nDoodads);
290 XkbcAllocGeomSectionDoodads(XkbSectionPtr section, int nDoodads);
293 XkbcAllocGeomOutlines(XkbShapePtr shape, int nOL);
296 XkbcAllocGeomRows(XkbSectionPtr section, int nRows);
299 XkbcAllocGeomPoints(XkbOutlinePtr ol, int nPts);
302 XkbcAllocGeomKeys(XkbRowPtr row, int nKeys);
305 XkbcAllocGeometry(XkbcDescPtr xkb, XkbGeometrySizesPtr sizes);
307 extern XkbPropertyPtr
308 XkbcAddGeomProperty(XkbGeometryPtr geom, char *name, char *value);
310 extern XkbKeyAliasPtr
311 XkbcAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr);
314 XkbcAddGeomColor(XkbGeometryPtr geom, char *spec, unsigned int pixel);
317 XkbcAddGeomOutline(XkbShapePtr shape, int sz_points);
320 XkbcAddGeomShape(XkbGeometryPtr geom, Atom name, int sz_outlines);
323 XkbcAddGeomKey(XkbRowPtr row);
326 XkbcAddGeomRow(XkbSectionPtr section, int sz_keys);
329 XkbcAddGeomSection(XkbGeometryPtr geom, Atom name,
330 int sz_rows, int sz_doodads, int sz_over);
333 XkbcAddGeomDoodad(XkbGeometryPtr geom, XkbSectionPtr section, Atom name);
335 extern XkbOverlayKeyPtr
336 XkbcAddGeomOverlayKey(XkbOverlayPtr overlay, XkbOverlayRowPtr row,
337 char *over, char *under);
339 extern XkbOverlayRowPtr
340 XkbcAddGeomOverlayRow(XkbOverlayPtr overlay, int row_under, int sz_keys);
343 XkbcAddGeomOverlay(XkbSectionPtr section, Atom name, int sz_rows);
349 XkbcAtomGetString(Atom atom);
352 XkbcInternAtom(char *name, Bool onlyIfExists);
355 XkbcAtomText(Atom atm);
358 XkbcVModIndexText(XkbcDescPtr xkb, unsigned ndx);
361 XkbcVModMaskText(XkbcDescPtr xkb, unsigned modMask, unsigned mask);
364 XkbcModIndexText(unsigned ndx);
367 XkbcModMaskText(unsigned mask, Bool cFormat);
370 XkbcConfigText(unsigned config);
373 XkbcGeomFPText(int val);
376 XkbcActionTypeText(unsigned type);
379 XkbcKeysymText(KeySym sym);
382 XkbcKeyNameText(char *name);
385 XkbcSIMatchText(unsigned type);
388 XkbcComputeShapeBounds(XkbShapePtr shape);
391 XkbcComputeShapeTop(XkbShapePtr shape, XkbBoundsPtr bounds);
394 XkbcComputeRowBounds(XkbGeometryPtr geom, XkbSectionPtr section, XkbRowPtr row);
397 XkbcComputeSectionBounds(XkbGeometryPtr geom, XkbSectionPtr section);
400 XkbcRF_GetComponents(XkbRF_RulesPtr rules, XkbRF_VarDefsPtr defs,
401 XkbComponentNamesPtr names);
404 XkbcRF_AddRule(XkbRF_RulesPtr rules);
406 extern XkbRF_GroupPtr
407 XkbcRF_AddGroup(XkbRF_RulesPtr rules);
410 XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
413 XkbcRF_LoadRulesByName(char *base, char *locale, XkbRF_RulesPtr rules);
415 extern XkbRF_VarDescPtr
416 XkbcRF_AddVarDesc(XkbRF_DescribeVarsPtr vars);
418 extern XkbRF_VarDescPtr
419 XkbcRF_AddVarDescCopy(XkbRF_DescribeVarsPtr vars, XkbRF_VarDescPtr from);
421 extern XkbRF_DescribeVarsPtr
422 XkbcRF_AddVarToDescribe(XkbRF_RulesPtr rules, char *name);
425 XkbcRF_LoadDescriptions(FILE *file, XkbRF_RulesPtr rules);
428 XkbcRF_LoadDescriptionsByName(char *base, char *locale, XkbRF_RulesPtr rules);
430 extern XkbRF_RulesPtr
431 XkbcRF_Load(char *base, char *locale, Bool wantDesc, Bool wantRules);
433 extern XkbRF_RulesPtr
434 XkbcRF_Create(int szRules, int szExtra);
437 XkbcRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
440 XkbcInitCanonicalKeyTypes(XkbcDescPtr xkb, unsigned which, int keypadVMod);
443 XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask,
444 unsigned *mask_rtrn);
447 XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
448 unsigned char *map_rtrn);
451 XkbcEnsureSafeMapName(char *name);
454 _XkbcKSCheckCase(KeySym sym);
458 #endif /* _XKBCOMMON_H_ */