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.
28 /************************************************************
29 Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
31 Permission to use, copy, modify, and distribute this
32 software and its documentation for any purpose and without
33 fee is hereby granted, provided that the above copyright
34 notice appear in all copies and that both that copyright
35 notice and this permission notice appear in supporting
36 documentation, and that the name of Silicon Graphics not be
37 used in advertising or publicity pertaining to distribution
38 of the software without specific prior written permission.
39 Silicon Graphics makes no representation about the suitability
40 of this software for any purpose. It is provided "as is"
41 without any express or implied warranty.
43 SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
44 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
45 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
46 GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
47 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
48 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
49 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
50 THE USE OR PERFORMANCE OF THIS SOFTWARE.
52 ********************************************************/
60 #include <X11/Xfuncproto.h>
62 #include <X11/extensions/XKBstrcommon.h>
63 #include <X11/extensions/XKBrulescommon.h>
65 /* Action structures used in the server */
67 #define XkbcAnyActionDataSize 18
68 typedef struct _XkbcAnyAction {
70 unsigned char pad[XkbcAnyActionDataSize];
73 typedef struct _XkbcModAction {
81 typedef struct _XkbcGroupAction {
87 typedef struct _XkbcISOAction {
97 typedef struct _XkbcCtrlsAction {
103 typedef struct _XkbcDeviceBtnAction {
109 } XkbcDeviceBtnAction;
111 typedef struct _XkbcDeviceValuatorAction {
120 } XkbcDeviceValuatorAction;
122 typedef struct _XkbcPtrDfltAction {
129 typedef struct _XkbcSwitchScreenAction {
133 } XkbcSwitchScreenAction;
135 typedef union _XkbcAction {
138 XkbcGroupAction group;
140 XkbcCtrlsAction ctrls;
141 XkbcDeviceBtnAction devbtn;
142 XkbcDeviceValuatorAction devval;
143 XkbcPtrDfltAction dflt;
144 XkbcSwitchScreenAction screen;
145 XkbRedirectKeyAction redirect; /* XXX wholly unnecessary? */
146 XkbPtrAction ptr; /* XXX delete for DeviceValuator */
147 XkbPtrBtnAction btn; /* XXX delete for DeviceBtn */
148 XkbMessageAction msg; /* XXX just delete */
152 typedef struct _XkbcKeyType {
154 unsigned char num_levels;
155 unsigned char map_count;
156 XkbKTMapEntryPtr map;
160 } XkbcKeyTypeRec, *XkbcKeyTypePtr;
162 typedef struct _XkbcSymInterpretRec {
167 unsigned char virtual_mod;
169 } XkbcSymInterpretRec, *XkbcSymInterpretPtr;
171 typedef struct _XkbcCompatMapRec {
172 XkbcSymInterpretPtr sym_interpret;
173 XkbModsRec groups[XkbNumKbdGroups];
174 unsigned short num_si;
175 unsigned short size_si;
176 } XkbcCompatMapRec, *XkbcCompatMapPtr;
178 typedef struct _XkbcClientMapRec {
179 unsigned char size_types;
180 unsigned char num_types;
181 XkbcKeyTypePtr types;
183 unsigned short size_syms;
184 unsigned short num_syms;
186 XkbSymMapPtr key_sym_map;
188 unsigned char *modmap;
189 } XkbcClientMapRec, *XkbcClientMapPtr;
191 typedef struct _XkbcServerMapRec {
192 unsigned short num_acts;
193 unsigned short size_acts;
195 #if defined(__cplusplus) || defined(c_plusplus)
196 /* explicit is a C++ reserved word */
197 unsigned char * c_explicit;
199 unsigned char * explicit;
203 XkbBehavior *behaviors;
204 unsigned short *key_acts;
205 unsigned char *explicits;
206 uint32_t vmods[XkbNumVirtualMods];
208 } XkbcServerMapRec, *XkbcServerMapPtr;
210 typedef struct _XkbcNamesRec {
216 CARD32 vmods[XkbNumVirtualMods];
217 CARD32 indicators[XkbNumIndicators];
218 CARD32 groups[XkbNumKbdGroups];
220 XkbKeyAliasPtr key_aliases;
221 CARD32 *radio_groups;
224 unsigned char num_keys;
225 unsigned char num_key_aliases;
226 unsigned short num_rg;
227 } XkbcNamesRec, *XkbcNamesPtr;
229 typedef struct _XkbcProperty {
232 } XkbcPropertyRec, *XkbcPropertyPtr;
234 typedef struct _XkbcColor {
237 } XkbcColorRec, *XkbcColorPtr;
239 typedef struct _XkbcPoint {
242 } XkbcPointRec, *XkbcPointPtr;
244 typedef struct _XkbcBounds {
247 } XkbcBoundsRec, *XkbcBoundsPtr;
248 #define XkbBoundsWidth(b) (((b)->x2)-((b)->x1))
249 #define XkbBoundsHeight(b) (((b)->y2)-((b)->y1))
251 typedef struct _XkbcOutline {
252 unsigned short num_points;
253 unsigned short sz_points;
254 unsigned short corner_radius;
256 } XkbcOutlineRec, *XkbcOutlinePtr;
258 typedef struct _XkbcShape {
260 unsigned short num_outlines;
261 unsigned short sz_outlines;
262 XkbcOutlinePtr outlines;
263 XkbcOutlinePtr approx;
264 XkbcOutlinePtr primary;
265 XkbcBoundsRec bounds;
266 } XkbcShapeRec, *XkbcShapePtr;
267 #define XkbOutlineIndex(s,o) ((int)((o)-&(s)->outlines[0]))
269 typedef struct _XkbcShapeDoodad {
272 unsigned char priority;
276 unsigned short color_ndx;
277 unsigned short shape_ndx;
278 } XkbcShapeDoodadRec, *XkbcShapeDoodadPtr;
279 #define XkbShapeDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
280 #define XkbShapeDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
281 #define XkbSetShapeDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
282 #define XkbSetShapeDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
284 typedef struct _XkbcTextDoodad {
287 unsigned char priority;
293 unsigned short color_ndx;
296 } XkbcTextDoodadRec, *XkbcTextDoodadPtr;
297 #define XkbTextDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
298 #define XkbSetTextDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
300 typedef struct _XkbcIndicatorDoodad {
303 unsigned char priority;
307 unsigned short shape_ndx;
308 unsigned short on_color_ndx;
309 unsigned short off_color_ndx;
310 } XkbcIndicatorDoodadRec, *XkbcIndicatorDoodadPtr;
311 #define XkbIndicatorDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
312 #define XkbIndicatorDoodadOnColor(g,d) (&(g)->colors[(d)->on_color_ndx])
313 #define XkbIndicatorDoodadOffColor(g,d) (&(g)->colors[(d)->off_color_ndx])
314 #define XkbSetIndicatorDoodadOnColor(g,d,c) \
315 ((d)->on_color_ndx= (c)-&(g)->colors[0])
316 #define XkbSetIndicatorDoodadOffColor(g,d,c) \
317 ((d)->off_color_ndx= (c)-&(g)->colors[0])
318 #define XkbSetIndicatorDoodadShape(g,d,s) \
319 ((d)->shape_ndx= (s)-&(g)->shapes[0])
321 typedef struct _XkbcLogoDoodad {
324 unsigned char priority;
328 unsigned short color_ndx;
329 unsigned short shape_ndx;
331 } XkbcLogoDoodadRec, *XkbcLogoDoodadPtr;
332 #define XkbLogoDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
333 #define XkbLogoDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
334 #define XkbSetLogoDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
335 #define XkbSetLogoDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
337 typedef struct _XkbcAnyDoodad {
340 unsigned char priority;
344 } XkbcAnyDoodadRec, *XkbcAnyDoodadPtr;
346 typedef union _XkbcDoodad {
347 XkbcAnyDoodadRec any;
348 XkbcShapeDoodadRec shape;
349 XkbcTextDoodadRec text;
350 XkbcIndicatorDoodadRec indicator;
351 XkbcLogoDoodadRec logo;
352 } XkbcDoodadRec, *XkbcDoodadPtr;
354 #define XkbUnknownDoodad 0
355 #define XkbOutlineDoodad 1
356 #define XkbSolidDoodad 2
357 #define XkbTextDoodad 3
358 #define XkbIndicatorDoodad 4
359 #define XkbLogoDoodad 5
361 typedef struct _XkbcKey {
364 unsigned char shape_ndx;
365 unsigned char color_ndx;
366 } XkbcKeyRec, *XkbcKeyPtr;
367 #define XkbKeyShape(g,k) (&(g)->shapes[(k)->shape_ndx])
368 #define XkbKeyColor(g,k) (&(g)->colors[(k)->color_ndx])
369 #define XkbSetKeyShape(g,k,s) ((k)->shape_ndx= (s)-&(g)->shapes[0])
370 #define XkbSetKeyColor(g,k,c) ((k)->color_ndx= (c)-&(g)->colors[0])
372 typedef struct _XkbRow {
375 unsigned short num_keys;
376 unsigned short sz_keys;
379 XkbcBoundsRec bounds;
380 } XkbcRowRec, *XkbcRowPtr;
382 typedef struct _XkbcSection {
384 unsigned char priority;
387 unsigned short width;
388 unsigned short height;
390 unsigned short num_rows;
391 unsigned short num_doodads;
392 unsigned short num_overlays;
393 unsigned short sz_rows;
394 unsigned short sz_doodads;
395 unsigned short sz_overlays;
397 XkbcDoodadPtr doodads;
398 XkbcBoundsRec bounds;
399 struct _XkbOverlay *overlays;
400 } XkbcSectionRec, *XkbcSectionPtr;
402 typedef struct _XkbcOverlayKey {
405 } XkbcOverlayKeyRec, *XkbcOverlayKeyPtr;
407 typedef struct _XkbOverlayRow {
408 unsigned short row_under;
409 unsigned short num_keys;
410 unsigned short sz_keys;
411 XkbcOverlayKeyPtr keys;
412 } XkbcOverlayRowRec, *XkbcOverlayRowPtr;
414 typedef struct _XkbOverlay {
416 XkbcSectionPtr section_under;
417 unsigned short num_rows;
418 unsigned short sz_rows;
419 XkbcOverlayRowPtr rows;
420 XkbcBoundsPtr bounds;
421 } XkbcOverlayRec, *XkbcOverlayPtr;
423 typedef struct _XkbcGeometry {
425 unsigned short width_mm;
426 unsigned short height_mm;
428 XkbcColorPtr label_color;
429 XkbcColorPtr base_color;
430 unsigned short sz_properties;
431 unsigned short sz_colors;
432 unsigned short sz_shapes;
433 unsigned short sz_sections;
434 unsigned short sz_doodads;
435 unsigned short sz_key_aliases;
436 unsigned short num_properties;
437 unsigned short num_colors;
438 unsigned short num_shapes;
439 unsigned short num_sections;
440 unsigned short num_doodads;
441 unsigned short num_key_aliases;
442 XkbcPropertyPtr properties;
445 XkbcSectionPtr sections;
446 XkbcDoodadPtr doodads;
447 XkbKeyAliasPtr key_aliases;
448 } XkbcGeometryRec, *XkbcGeometryPtr;
449 #define XkbGeomColorIndex(g,c) ((int)((c)-&(g)->colors[0]))
451 #define XkbGeomPropertiesMask (1<<0)
452 #define XkbGeomColorsMask (1<<1)
453 #define XkbGeomShapesMask (1<<2)
454 #define XkbGeomSectionsMask (1<<3)
455 #define XkbGeomDoodadsMask (1<<4)
456 #define XkbGeomKeyAliasesMask (1<<5)
457 #define XkbGeomAllMask (0x3f)
459 typedef struct _XkbcGeometrySizes {
461 unsigned short num_properties;
462 unsigned short num_colors;
463 unsigned short num_shapes;
464 unsigned short num_sections;
465 unsigned short num_doodads;
466 unsigned short num_key_aliases;
467 } XkbcGeometrySizesRec, *XkbcGeometrySizesPtr;
469 /* Common keyboard description structure */
470 typedef struct _XkbcDesc {
471 unsigned int defined;
472 unsigned short flags;
473 unsigned short device_spec;
474 KeyCode min_key_code;
475 KeyCode max_key_code;
477 XkbControlsPtr ctrls;
478 XkbcServerMapPtr server;
479 XkbcClientMapPtr map;
480 XkbIndicatorPtr indicators;
482 XkbcCompatMapPtr compat;
483 XkbcGeometryPtr geom;
484 } XkbcDescRec, *XkbcDescPtr;
488 typedef uint32_t (*InternAtomFuncPtr)(const char *val);
489 typedef const char *(*GetAtomValueFuncPtr)(uint32_t atom);
492 XkbcInitAtoms(InternAtomFuncPtr intern, GetAtomValueFuncPtr get_atom_value);
495 XkbcCompileKeymapFromRules(const XkbRMLVOSet *rmlvo);
498 XkbcCompileKeymapFromComponents(const XkbComponentNamesPtr ktcsg);
501 XkbcCompileKeymapFromFile(FILE *inputFile, const char *mapName);
503 extern XkbComponentListPtr
504 XkbcListComponents(XkbComponentNamesPtr ptrns, int *maxMatch);
507 * Canonicalises component names by prepending the relevant component from
508 * 'old' to the one in 'names' when the latter has a leading '+' or '|', and
509 * by replacing a '%' with the relevant component, e.g.:
512 * ------------------------------------------
515 * foo+%|baz bar foo+bar|baz
517 * If a component in names needs to be modified, the existing value will be
518 * free()d, and a new one allocated with malloc().
521 XkbcCanonicaliseComponents(XkbComponentNamesPtr names,
522 const XkbComponentNamesPtr old);
525 * Converts a keysym to a string; will return unknown Unicode codepoints
526 * as "Ua1b2", and other unknown keysyms as "0xabcd1234".
528 * The string returned may become invalidated after the next call to
529 * XkbcKeysymToString: if you need to preserve it, then you must
532 * This is CARD32 rather than KeySym, as KeySym changes size between
533 * client and server (no, really).
536 XkbcKeysymToString(CARD32 ks);
539 * See XkbcKeysymToString comments: this function will accept any string
540 * from that function.
543 XkbcStringToKeysym(const char *s);
547 #endif /* _XKBCOMMON_H_ */