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 struct xkb_any_action {
70 unsigned char pad[XkbcAnyActionDataSize];
73 struct xkb_mod_action {
81 struct xkb_group_action {
87 struct xkb_iso_action {
98 struct xkb_controls_action {
104 struct xkb_device_button_action {
112 struct xkb_device_valuator_action {
123 struct xkb_pointer_default_action {
130 struct xkb_switch_screen_action {
136 struct xkb_redirect_key_action {
138 unsigned char new_key;
139 unsigned char mods_mask;
141 unsigned char vmods_mask0;
142 unsigned char vmods_mask1;
143 unsigned char vmods0;
144 unsigned char vmods1;
147 struct xkb_pointer_action {
150 unsigned char high_XXX;
151 unsigned char low_XXX;
152 unsigned char high_YYY;
153 unsigned char low_YYY;
156 struct xkb_message_action {
159 unsigned char message[6];
162 struct xkb_pointer_button_action {
166 unsigned char button;
170 struct xkb_any_action any;
171 struct xkb_mod_action mods;
172 struct xkb_group_action group;
173 struct xkb_iso_action iso;
174 struct xkb_controls_action ctrls;
175 struct xkb_device_button_action devbtn;
176 struct xkb_device_valuator_action devval;
177 struct xkb_pointer_default_action dflt;
178 struct xkb_switch_screen_action screen;
179 struct xkb_redirect_key_action redirect; /* XXX wholly unnecessary? */
180 struct xkb_pointer_action ptr; /* XXX delete for DeviceValuator */
181 struct xkb_pointer_button_action btn; /* XXX delete for DeviceBtn */
182 struct xkb_message_action msg; /* XXX just delete */
186 typedef struct _XkbcMods {
187 uint32_t mask; /* effective mods */
190 } XkbcModsRec, *XkbcModsPtr;
192 typedef struct _XkbcKTMapEntry {
196 } XkbcKTMapEntryRec, *XkbcKTMapEntryPtr;
198 typedef struct _XkbcKeyType {
201 unsigned char map_count;
202 XkbcKTMapEntryPtr map;
203 XkbcModsPtr preserve;
205 uint32_t *level_names;
206 } XkbcKeyTypeRec, *XkbcKeyTypePtr;
208 typedef struct _XkbcSymInterpretRec {
212 uint8_t mods; /* XXX real or virt? */
213 uint32_t virtual_mod;
214 struct xkb_any_action act;
215 } XkbcSymInterpretRec, *XkbcSymInterpretPtr;
217 typedef struct _XkbcCompatMapRec {
218 XkbcSymInterpretPtr sym_interpret;
219 XkbcModsRec groups[XkbNumKbdGroups];
220 unsigned short num_si;
221 unsigned short size_si;
222 } XkbcCompatMapRec, *XkbcCompatMapPtr;
224 typedef struct _XkbcClientMapRec {
225 unsigned char size_types;
226 unsigned char num_types;
227 XkbcKeyTypePtr types;
229 unsigned short size_syms;
230 unsigned short num_syms;
232 XkbSymMapPtr key_sym_map;
234 unsigned char *modmap;
235 } XkbcClientMapRec, *XkbcClientMapPtr;
237 typedef struct _XkbcServerMapRec {
238 unsigned short num_acts;
239 unsigned short size_acts;
241 #if defined(__cplusplus) || defined(c_plusplus)
242 /* explicit is a C++ reserved word */
243 unsigned char * c_explicit;
245 unsigned char * explicit;
248 union xkb_action *acts;
249 XkbBehavior *behaviors;
250 unsigned short *key_acts;
251 unsigned char *explicits;
252 uint32_t vmods[XkbNumVirtualMods];
254 } XkbcServerMapRec, *XkbcServerMapPtr;
256 typedef struct _XkbcNamesRec {
262 uint32_t vmods[XkbNumVirtualMods];
263 uint32_t indicators[XkbNumIndicators];
264 uint32_t groups[XkbNumKbdGroups];
266 XkbKeyAliasPtr key_aliases;
267 uint32_t *radio_groups;
268 uint32_t phys_symbols;
270 unsigned char num_keys;
271 unsigned char num_key_aliases;
272 unsigned short num_rg;
273 } XkbcNamesRec, *XkbcNamesPtr;
275 typedef struct _XkbcProperty {
278 } XkbcPropertyRec, *XkbcPropertyPtr;
280 typedef struct _XkbcColor {
283 } XkbcColorRec, *XkbcColorPtr;
285 typedef struct _XkbcPoint {
288 } XkbcPointRec, *XkbcPointPtr;
290 typedef struct _XkbcBounds {
293 } XkbcBoundsRec, *XkbcBoundsPtr;
294 #define XkbBoundsWidth(b) (((b)->x2)-((b)->x1))
295 #define XkbBoundsHeight(b) (((b)->y2)-((b)->y1))
297 typedef struct _XkbcOutline {
298 unsigned short num_points;
299 unsigned short sz_points;
300 unsigned short corner_radius;
302 } XkbcOutlineRec, *XkbcOutlinePtr;
304 typedef struct _XkbcShape {
306 unsigned short num_outlines;
307 unsigned short sz_outlines;
308 XkbcOutlinePtr outlines;
309 XkbcOutlinePtr approx;
310 XkbcOutlinePtr primary;
311 XkbcBoundsRec bounds;
312 } XkbcShapeRec, *XkbcShapePtr;
313 #define XkbOutlineIndex(s,o) ((int)((o)-&(s)->outlines[0]))
315 typedef struct _XkbcShapeDoodad {
318 unsigned char priority;
322 unsigned short color_ndx;
323 unsigned short shape_ndx;
324 } XkbcShapeDoodadRec, *XkbcShapeDoodadPtr;
325 #define XkbShapeDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
326 #define XkbShapeDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
327 #define XkbSetShapeDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
328 #define XkbSetShapeDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
330 typedef struct _XkbcTextDoodad {
333 unsigned char priority;
339 unsigned short color_ndx;
342 } XkbcTextDoodadRec, *XkbcTextDoodadPtr;
343 #define XkbTextDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
344 #define XkbSetTextDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
346 typedef struct _XkbcIndicatorDoodad {
349 unsigned char priority;
353 unsigned short shape_ndx;
354 unsigned short on_color_ndx;
355 unsigned short off_color_ndx;
356 } XkbcIndicatorDoodadRec, *XkbcIndicatorDoodadPtr;
357 #define XkbIndicatorDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
358 #define XkbIndicatorDoodadOnColor(g,d) (&(g)->colors[(d)->on_color_ndx])
359 #define XkbIndicatorDoodadOffColor(g,d) (&(g)->colors[(d)->off_color_ndx])
360 #define XkbSetIndicatorDoodadOnColor(g,d,c) \
361 ((d)->on_color_ndx= (c)-&(g)->colors[0])
362 #define XkbSetIndicatorDoodadOffColor(g,d,c) \
363 ((d)->off_color_ndx= (c)-&(g)->colors[0])
364 #define XkbSetIndicatorDoodadShape(g,d,s) \
365 ((d)->shape_ndx= (s)-&(g)->shapes[0])
367 typedef struct _XkbcLogoDoodad {
370 unsigned char priority;
374 unsigned short color_ndx;
375 unsigned short shape_ndx;
377 } XkbcLogoDoodadRec, *XkbcLogoDoodadPtr;
378 #define XkbLogoDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
379 #define XkbLogoDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
380 #define XkbSetLogoDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
381 #define XkbSetLogoDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
383 typedef struct _XkbcAnyDoodad {
386 unsigned char priority;
390 } XkbcAnyDoodadRec, *XkbcAnyDoodadPtr;
392 typedef union _XkbcDoodad {
393 XkbcAnyDoodadRec any;
394 XkbcShapeDoodadRec shape;
395 XkbcTextDoodadRec text;
396 XkbcIndicatorDoodadRec indicator;
397 XkbcLogoDoodadRec logo;
398 } XkbcDoodadRec, *XkbcDoodadPtr;
400 #define XkbUnknownDoodad 0
401 #define XkbOutlineDoodad 1
402 #define XkbSolidDoodad 2
403 #define XkbTextDoodad 3
404 #define XkbIndicatorDoodad 4
405 #define XkbLogoDoodad 5
407 typedef struct _XkbcKey {
410 unsigned char shape_ndx;
411 unsigned char color_ndx;
412 } XkbcKeyRec, *XkbcKeyPtr;
413 #define XkbKeyShape(g,k) (&(g)->shapes[(k)->shape_ndx])
414 #define XkbKeyColor(g,k) (&(g)->colors[(k)->color_ndx])
415 #define XkbSetKeyShape(g,k,s) ((k)->shape_ndx= (s)-&(g)->shapes[0])
416 #define XkbSetKeyColor(g,k,c) ((k)->color_ndx= (c)-&(g)->colors[0])
418 typedef struct _XkbRow {
421 unsigned short num_keys;
422 unsigned short sz_keys;
425 XkbcBoundsRec bounds;
426 } XkbcRowRec, *XkbcRowPtr;
428 typedef struct _XkbcSection {
430 unsigned char priority;
433 unsigned short width;
434 unsigned short height;
436 unsigned short num_rows;
437 unsigned short num_doodads;
438 unsigned short num_overlays;
439 unsigned short sz_rows;
440 unsigned short sz_doodads;
441 unsigned short sz_overlays;
443 XkbcDoodadPtr doodads;
444 XkbcBoundsRec bounds;
445 struct _XkbOverlay *overlays;
446 } XkbcSectionRec, *XkbcSectionPtr;
448 typedef struct _XkbcOverlayKey {
451 } XkbcOverlayKeyRec, *XkbcOverlayKeyPtr;
453 typedef struct _XkbOverlayRow {
454 unsigned short row_under;
455 unsigned short num_keys;
456 unsigned short sz_keys;
457 XkbcOverlayKeyPtr keys;
458 } XkbcOverlayRowRec, *XkbcOverlayRowPtr;
460 typedef struct _XkbOverlay {
462 XkbcSectionPtr section_under;
463 unsigned short num_rows;
464 unsigned short sz_rows;
465 XkbcOverlayRowPtr rows;
466 XkbcBoundsPtr bounds;
467 } XkbcOverlayRec, *XkbcOverlayPtr;
469 typedef struct _XkbcGeometry {
471 unsigned short width_mm;
472 unsigned short height_mm;
474 XkbcColorPtr label_color;
475 XkbcColorPtr base_color;
476 unsigned short sz_properties;
477 unsigned short sz_colors;
478 unsigned short sz_shapes;
479 unsigned short sz_sections;
480 unsigned short sz_doodads;
481 unsigned short sz_key_aliases;
482 unsigned short num_properties;
483 unsigned short num_colors;
484 unsigned short num_shapes;
485 unsigned short num_sections;
486 unsigned short num_doodads;
487 unsigned short num_key_aliases;
488 XkbcPropertyPtr properties;
491 XkbcSectionPtr sections;
492 XkbcDoodadPtr doodads;
493 XkbKeyAliasPtr key_aliases;
494 } XkbcGeometryRec, *XkbcGeometryPtr;
495 #define XkbGeomColorIndex(g,c) ((int)((c)-&(g)->colors[0]))
497 #define XkbGeomPropertiesMask (1<<0)
498 #define XkbGeomColorsMask (1<<1)
499 #define XkbGeomShapesMask (1<<2)
500 #define XkbGeomSectionsMask (1<<3)
501 #define XkbGeomDoodadsMask (1<<4)
502 #define XkbGeomKeyAliasesMask (1<<5)
503 #define XkbGeomAllMask (0x3f)
505 typedef struct _XkbcGeometrySizes {
507 unsigned short num_properties;
508 unsigned short num_colors;
509 unsigned short num_shapes;
510 unsigned short num_sections;
511 unsigned short num_doodads;
512 unsigned short num_key_aliases;
513 } XkbcGeometrySizesRec, *XkbcGeometrySizesPtr;
515 /* Common keyboard description structure */
516 typedef struct _XkbcDesc {
517 unsigned int defined;
518 unsigned short flags;
519 unsigned short device_spec;
520 KeyCode min_key_code;
521 KeyCode max_key_code;
523 XkbControlsPtr ctrls;
524 XkbcServerMapPtr server;
525 XkbcClientMapPtr map;
526 XkbIndicatorPtr indicators;
528 XkbcCompatMapPtr compat;
529 XkbcGeometryPtr geom;
530 } XkbcDescRec, *XkbcDescPtr;
534 typedef uint32_t (*InternAtomFuncPtr)(const char *val);
535 typedef const char *(*GetAtomValueFuncPtr)(uint32_t atom);
538 XkbcInitAtoms(InternAtomFuncPtr intern, GetAtomValueFuncPtr get_atom_value);
541 XkbcCompileKeymapFromRules(const XkbRMLVOSet *rmlvo);
544 XkbcCompileKeymapFromComponents(const XkbComponentNamesPtr ktcsg);
547 XkbcCompileKeymapFromFile(FILE *inputFile, const char *mapName);
549 extern XkbComponentListPtr
550 XkbcListComponents(XkbComponentNamesPtr ptrns, int *maxMatch);
553 * Canonicalises component names by prepending the relevant component from
554 * 'old' to the one in 'names' when the latter has a leading '+' or '|', and
555 * by replacing a '%' with the relevant component, e.g.:
558 * ------------------------------------------
561 * foo+%|baz bar foo+bar|baz
563 * If a component in names needs to be modified, the existing value will be
564 * free()d, and a new one allocated with malloc().
567 XkbcCanonicaliseComponents(XkbComponentNamesPtr names,
568 const XkbComponentNamesPtr old);
571 * Converts a keysym to a string; will return unknown Unicode codepoints
572 * as "Ua1b2", and other unknown keysyms as "0xabcd1234".
574 * The string returned may become invalidated after the next call to
575 * XkbcKeysymToString: if you need to preserve it, then you must
578 * This is uint32_t rather than KeySym, as KeySym changes size between
579 * client and server (no, really).
582 XkbcKeysymToString(uint32_t ks);
585 * See XkbcKeysymToString comments: this function will accept any string
586 * from that function.
589 XkbcStringToKeysym(const char *s);
593 #endif /* _XKBCOMMON_H_ */