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 {
137 struct xkb_any_action any;
138 struct xkb_mod_action mods;
139 struct xkb_group_action group;
140 struct xkb_iso_action iso;
141 struct xkb_controls_action ctrls;
142 struct xkb_device_button_action devbtn;
143 struct xkb_device_valuator_action devval;
144 struct xkb_pointer_default_action dflt;
145 struct xkb_switch_screen_action screen;
146 XkbRedirectKeyAction redirect; /* XXX wholly unnecessary? */
147 XkbPtrAction ptr; /* XXX delete for DeviceValuator */
148 XkbPtrBtnAction btn; /* XXX delete for DeviceBtn */
149 XkbMessageAction msg; /* XXX just delete */
153 typedef struct _XkbcMods {
154 uint32_t mask; /* effective mods */
157 } XkbcModsRec, *XkbcModsPtr;
159 typedef struct _XkbcKTMapEntry {
163 } XkbcKTMapEntryRec, *XkbcKTMapEntryPtr;
165 typedef struct _XkbcKeyType {
168 unsigned char map_count;
169 XkbcKTMapEntryPtr map;
170 XkbcModsPtr preserve;
172 uint32_t *level_names;
173 } XkbcKeyTypeRec, *XkbcKeyTypePtr;
175 typedef struct _XkbcSymInterpretRec {
179 uint8_t mods; /* XXX real or virt? */
180 uint32_t virtual_mod;
181 struct xkb_any_action act;
182 } XkbcSymInterpretRec, *XkbcSymInterpretPtr;
184 typedef struct _XkbcCompatMapRec {
185 XkbcSymInterpretPtr sym_interpret;
186 XkbcModsRec groups[XkbNumKbdGroups];
187 unsigned short num_si;
188 unsigned short size_si;
189 } XkbcCompatMapRec, *XkbcCompatMapPtr;
191 typedef struct _XkbcClientMapRec {
192 unsigned char size_types;
193 unsigned char num_types;
194 XkbcKeyTypePtr types;
196 unsigned short size_syms;
197 unsigned short num_syms;
199 XkbSymMapPtr key_sym_map;
201 unsigned char *modmap;
202 } XkbcClientMapRec, *XkbcClientMapPtr;
204 typedef struct _XkbcServerMapRec {
205 unsigned short num_acts;
206 unsigned short size_acts;
208 #if defined(__cplusplus) || defined(c_plusplus)
209 /* explicit is a C++ reserved word */
210 unsigned char * c_explicit;
212 unsigned char * explicit;
215 union xkb_action *acts;
216 XkbBehavior *behaviors;
217 unsigned short *key_acts;
218 unsigned char *explicits;
219 uint32_t vmods[XkbNumVirtualMods];
221 } XkbcServerMapRec, *XkbcServerMapPtr;
223 typedef struct _XkbcNamesRec {
229 uint32_t vmods[XkbNumVirtualMods];
230 uint32_t indicators[XkbNumIndicators];
231 uint32_t groups[XkbNumKbdGroups];
233 XkbKeyAliasPtr key_aliases;
234 uint32_t *radio_groups;
235 uint32_t phys_symbols;
237 unsigned char num_keys;
238 unsigned char num_key_aliases;
239 unsigned short num_rg;
240 } XkbcNamesRec, *XkbcNamesPtr;
242 typedef struct _XkbcProperty {
245 } XkbcPropertyRec, *XkbcPropertyPtr;
247 typedef struct _XkbcColor {
250 } XkbcColorRec, *XkbcColorPtr;
252 typedef struct _XkbcPoint {
255 } XkbcPointRec, *XkbcPointPtr;
257 typedef struct _XkbcBounds {
260 } XkbcBoundsRec, *XkbcBoundsPtr;
261 #define XkbBoundsWidth(b) (((b)->x2)-((b)->x1))
262 #define XkbBoundsHeight(b) (((b)->y2)-((b)->y1))
264 typedef struct _XkbcOutline {
265 unsigned short num_points;
266 unsigned short sz_points;
267 unsigned short corner_radius;
269 } XkbcOutlineRec, *XkbcOutlinePtr;
271 typedef struct _XkbcShape {
273 unsigned short num_outlines;
274 unsigned short sz_outlines;
275 XkbcOutlinePtr outlines;
276 XkbcOutlinePtr approx;
277 XkbcOutlinePtr primary;
278 XkbcBoundsRec bounds;
279 } XkbcShapeRec, *XkbcShapePtr;
280 #define XkbOutlineIndex(s,o) ((int)((o)-&(s)->outlines[0]))
282 typedef struct _XkbcShapeDoodad {
285 unsigned char priority;
289 unsigned short color_ndx;
290 unsigned short shape_ndx;
291 } XkbcShapeDoodadRec, *XkbcShapeDoodadPtr;
292 #define XkbShapeDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
293 #define XkbShapeDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
294 #define XkbSetShapeDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
295 #define XkbSetShapeDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
297 typedef struct _XkbcTextDoodad {
300 unsigned char priority;
306 unsigned short color_ndx;
309 } XkbcTextDoodadRec, *XkbcTextDoodadPtr;
310 #define XkbTextDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
311 #define XkbSetTextDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
313 typedef struct _XkbcIndicatorDoodad {
316 unsigned char priority;
320 unsigned short shape_ndx;
321 unsigned short on_color_ndx;
322 unsigned short off_color_ndx;
323 } XkbcIndicatorDoodadRec, *XkbcIndicatorDoodadPtr;
324 #define XkbIndicatorDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
325 #define XkbIndicatorDoodadOnColor(g,d) (&(g)->colors[(d)->on_color_ndx])
326 #define XkbIndicatorDoodadOffColor(g,d) (&(g)->colors[(d)->off_color_ndx])
327 #define XkbSetIndicatorDoodadOnColor(g,d,c) \
328 ((d)->on_color_ndx= (c)-&(g)->colors[0])
329 #define XkbSetIndicatorDoodadOffColor(g,d,c) \
330 ((d)->off_color_ndx= (c)-&(g)->colors[0])
331 #define XkbSetIndicatorDoodadShape(g,d,s) \
332 ((d)->shape_ndx= (s)-&(g)->shapes[0])
334 typedef struct _XkbcLogoDoodad {
337 unsigned char priority;
341 unsigned short color_ndx;
342 unsigned short shape_ndx;
344 } XkbcLogoDoodadRec, *XkbcLogoDoodadPtr;
345 #define XkbLogoDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
346 #define XkbLogoDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
347 #define XkbSetLogoDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
348 #define XkbSetLogoDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
350 typedef struct _XkbcAnyDoodad {
353 unsigned char priority;
357 } XkbcAnyDoodadRec, *XkbcAnyDoodadPtr;
359 typedef union _XkbcDoodad {
360 XkbcAnyDoodadRec any;
361 XkbcShapeDoodadRec shape;
362 XkbcTextDoodadRec text;
363 XkbcIndicatorDoodadRec indicator;
364 XkbcLogoDoodadRec logo;
365 } XkbcDoodadRec, *XkbcDoodadPtr;
367 #define XkbUnknownDoodad 0
368 #define XkbOutlineDoodad 1
369 #define XkbSolidDoodad 2
370 #define XkbTextDoodad 3
371 #define XkbIndicatorDoodad 4
372 #define XkbLogoDoodad 5
374 typedef struct _XkbcKey {
377 unsigned char shape_ndx;
378 unsigned char color_ndx;
379 } XkbcKeyRec, *XkbcKeyPtr;
380 #define XkbKeyShape(g,k) (&(g)->shapes[(k)->shape_ndx])
381 #define XkbKeyColor(g,k) (&(g)->colors[(k)->color_ndx])
382 #define XkbSetKeyShape(g,k,s) ((k)->shape_ndx= (s)-&(g)->shapes[0])
383 #define XkbSetKeyColor(g,k,c) ((k)->color_ndx= (c)-&(g)->colors[0])
385 typedef struct _XkbRow {
388 unsigned short num_keys;
389 unsigned short sz_keys;
392 XkbcBoundsRec bounds;
393 } XkbcRowRec, *XkbcRowPtr;
395 typedef struct _XkbcSection {
397 unsigned char priority;
400 unsigned short width;
401 unsigned short height;
403 unsigned short num_rows;
404 unsigned short num_doodads;
405 unsigned short num_overlays;
406 unsigned short sz_rows;
407 unsigned short sz_doodads;
408 unsigned short sz_overlays;
410 XkbcDoodadPtr doodads;
411 XkbcBoundsRec bounds;
412 struct _XkbOverlay *overlays;
413 } XkbcSectionRec, *XkbcSectionPtr;
415 typedef struct _XkbcOverlayKey {
418 } XkbcOverlayKeyRec, *XkbcOverlayKeyPtr;
420 typedef struct _XkbOverlayRow {
421 unsigned short row_under;
422 unsigned short num_keys;
423 unsigned short sz_keys;
424 XkbcOverlayKeyPtr keys;
425 } XkbcOverlayRowRec, *XkbcOverlayRowPtr;
427 typedef struct _XkbOverlay {
429 XkbcSectionPtr section_under;
430 unsigned short num_rows;
431 unsigned short sz_rows;
432 XkbcOverlayRowPtr rows;
433 XkbcBoundsPtr bounds;
434 } XkbcOverlayRec, *XkbcOverlayPtr;
436 typedef struct _XkbcGeometry {
438 unsigned short width_mm;
439 unsigned short height_mm;
441 XkbcColorPtr label_color;
442 XkbcColorPtr base_color;
443 unsigned short sz_properties;
444 unsigned short sz_colors;
445 unsigned short sz_shapes;
446 unsigned short sz_sections;
447 unsigned short sz_doodads;
448 unsigned short sz_key_aliases;
449 unsigned short num_properties;
450 unsigned short num_colors;
451 unsigned short num_shapes;
452 unsigned short num_sections;
453 unsigned short num_doodads;
454 unsigned short num_key_aliases;
455 XkbcPropertyPtr properties;
458 XkbcSectionPtr sections;
459 XkbcDoodadPtr doodads;
460 XkbKeyAliasPtr key_aliases;
461 } XkbcGeometryRec, *XkbcGeometryPtr;
462 #define XkbGeomColorIndex(g,c) ((int)((c)-&(g)->colors[0]))
464 #define XkbGeomPropertiesMask (1<<0)
465 #define XkbGeomColorsMask (1<<1)
466 #define XkbGeomShapesMask (1<<2)
467 #define XkbGeomSectionsMask (1<<3)
468 #define XkbGeomDoodadsMask (1<<4)
469 #define XkbGeomKeyAliasesMask (1<<5)
470 #define XkbGeomAllMask (0x3f)
472 typedef struct _XkbcGeometrySizes {
474 unsigned short num_properties;
475 unsigned short num_colors;
476 unsigned short num_shapes;
477 unsigned short num_sections;
478 unsigned short num_doodads;
479 unsigned short num_key_aliases;
480 } XkbcGeometrySizesRec, *XkbcGeometrySizesPtr;
482 /* Common keyboard description structure */
483 typedef struct _XkbcDesc {
484 unsigned int defined;
485 unsigned short flags;
486 unsigned short device_spec;
487 KeyCode min_key_code;
488 KeyCode max_key_code;
490 XkbControlsPtr ctrls;
491 XkbcServerMapPtr server;
492 XkbcClientMapPtr map;
493 XkbIndicatorPtr indicators;
495 XkbcCompatMapPtr compat;
496 XkbcGeometryPtr geom;
497 } XkbcDescRec, *XkbcDescPtr;
501 typedef uint32_t (*InternAtomFuncPtr)(const char *val);
502 typedef const char *(*GetAtomValueFuncPtr)(uint32_t atom);
505 XkbcInitAtoms(InternAtomFuncPtr intern, GetAtomValueFuncPtr get_atom_value);
508 XkbcCompileKeymapFromRules(const XkbRMLVOSet *rmlvo);
511 XkbcCompileKeymapFromComponents(const XkbComponentNamesPtr ktcsg);
514 XkbcCompileKeymapFromFile(FILE *inputFile, const char *mapName);
516 extern XkbComponentListPtr
517 XkbcListComponents(XkbComponentNamesPtr ptrns, int *maxMatch);
520 * Canonicalises component names by prepending the relevant component from
521 * 'old' to the one in 'names' when the latter has a leading '+' or '|', and
522 * by replacing a '%' with the relevant component, e.g.:
525 * ------------------------------------------
528 * foo+%|baz bar foo+bar|baz
530 * If a component in names needs to be modified, the existing value will be
531 * free()d, and a new one allocated with malloc().
534 XkbcCanonicaliseComponents(XkbComponentNamesPtr names,
535 const XkbComponentNamesPtr old);
538 * Converts a keysym to a string; will return unknown Unicode codepoints
539 * as "Ua1b2", and other unknown keysyms as "0xabcd1234".
541 * The string returned may become invalidated after the next call to
542 * XkbcKeysymToString: if you need to preserve it, then you must
545 * This is uint32_t rather than KeySym, as KeySym changes size between
546 * client and server (no, really).
549 XkbcKeysymToString(uint32_t ks);
552 * See XkbcKeysymToString comments: this function will accept any string
553 * from that function.
556 XkbcStringToKeysym(const char *s);
560 #endif /* _XKBCOMMON_H_ */