authorization from the authors.
*/
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+
#ifndef _XKBCOMMON_H_
#define _XKBCOMMON_H_
#include <stdint.h>
#include <stdio.h>
#include <X11/Xfuncproto.h>
+#include <X11/Xmd.h>
#include <X11/extensions/XKBstrcommon.h>
#include <X11/extensions/XKBrulescommon.h>
-#define KeySym CARD32
-#define Atom CARD32
-
/* Action structures used in the server */
#define XkbcAnyActionDataSize 18
-typedef struct _XkbcAnyAction {
+struct xkb_any_action {
unsigned char type;
unsigned char pad[XkbcAnyActionDataSize];
-} XkbcAnyAction;
+};
-typedef struct _XkbcModAction {
+struct xkb_mod_action {
unsigned char type;
uint8_t flags;
+ uint8_t real_mods;
uint32_t mask;
- uint32_t real_mods;
uint32_t vmods;
-} XkbcModAction;
+};
-typedef struct _XkbcGroupAction {
+struct xkb_group_action {
unsigned char type;
unsigned char flags;
int16_t group;
-} XkbcGroupAction;
+};
-typedef struct _XkbcISOAction {
+struct xkb_iso_action {
unsigned char type;
uint8_t flags;
int16_t group;
uint32_t mask;
uint32_t vmods;
- uint32_t real_mods;
- uint8_t affect;
-} XkbcISOAction;
+ uint8_t real_mods;
+
+ uint8_t affect;
+};
-typedef struct _XkbcCtrlsAction {
+struct xkb_controls_action {
unsigned char type;
- unsigned char flags;
+ uint8_t flags;
uint32_t ctrls;
-} XkbcCtrlsAction;
+};
-typedef struct _XkbcDeviceBtnAction {
+struct xkb_device_button_action {
unsigned char type;
- unsigned char flags;
+ uint8_t flags;
uint16_t device;
uint16_t button;
uint8_t count;
-} XkbcDeviceBtnAction;
+};
-typedef struct _XkbcDeviceValuatorAction {
+struct xkb_device_valuator_action {
unsigned char type;
uint8_t v1_what;
uint16_t device;
uint16_t v2_index;
int16_t v2_value;
uint8_t v2_what;
-} XkbcDeviceValuatorAction;
+};
-typedef struct _XkbcPtrDfltAction {
+struct xkb_pointer_default_action {
unsigned char type;
uint8_t flags;
uint8_t affect;
uint8_t value;
-} XkbcPtrDfltAction;
+};
-typedef struct _XkbcSwitchScreenAction {
+struct xkb_switch_screen_action {
unsigned char type;
uint8_t flags;
uint8_t screen;
-} XkbcSwitchScreenAction;
-
-typedef union _XkbcAction {
- XkbcAnyAction any;
- XkbcModAction mods;
- XkbcGroupAction group;
- XkbcISOAction iso;
- XkbcCtrlsAction ctrls;
- XkbcDeviceBtnAction devbtn;
- XkbcDeviceValuatorAction devval;
- XkbcPtrDfltAction dflt;
- XkbcSwitchScreenAction screen;
- XkbRedirectKeyAction redirect; /* XXX wholly unnecessary? */
- XkbPtrAction ptr; /* XXX delete for DeviceValuator */
- XkbPtrBtnAction btn; /* XXX delete for DeviceBtn */
- XkbMessageAction msg; /* XXX just delete */
- unsigned char type;
-} XkbcAction;
+};
+
+struct xkb_redirect_key_action {
+ unsigned char type;
+ unsigned char new_key;
+ unsigned char mods_mask;
+ unsigned char mods;
+ unsigned char vmods_mask0;
+ unsigned char vmods_mask1;
+ unsigned char vmods0;
+ unsigned char vmods1;
+};
+
+struct xkb_pointer_action {
+ unsigned char type;
+ unsigned char flags;
+ unsigned char high_XXX;
+ unsigned char low_XXX;
+ unsigned char high_YYY;
+ unsigned char low_YYY;
+};
+
+struct xkb_message_action {
+ unsigned char type;
+ unsigned char flags;
+ unsigned char message[6];
+};
+
+struct xkb_pointer_button_action {
+ unsigned char type;
+ unsigned char flags;
+ unsigned char count;
+ unsigned char button;
+};
+
+union xkb_action {
+ struct xkb_any_action any;
+ struct xkb_mod_action mods;
+ struct xkb_group_action group;
+ struct xkb_iso_action iso;
+ struct xkb_controls_action ctrls;
+ struct xkb_device_button_action devbtn;
+ struct xkb_device_valuator_action devval;
+ struct xkb_pointer_default_action dflt;
+ struct xkb_switch_screen_action screen;
+ struct xkb_redirect_key_action redirect; /* XXX wholly unnecessary? */
+ struct xkb_pointer_action ptr; /* XXX delete for DeviceValuator */
+ struct xkb_pointer_button_action btn; /* XXX delete for DeviceBtn */
+ struct xkb_message_action msg; /* XXX just delete */
+ unsigned char type;
+};
+
+typedef struct _XkbcMods {
+ uint32_t mask; /* effective mods */
+ uint32_t vmods;
+ uint8_t real_mods;
+} XkbcModsRec, *XkbcModsPtr;
+
+typedef struct _XkbcKTMapEntry {
+ Bool active;
+ uint16_t level;
+ XkbcModsRec mods;
+} XkbcKTMapEntryRec, *XkbcKTMapEntryPtr;
+
+typedef struct _XkbcKeyType {
+ XkbcModsRec mods;
+ uint16_t num_levels;
+ unsigned char map_count;
+ XkbcKTMapEntryPtr map;
+ XkbcModsPtr preserve;
+ uint32_t name;
+ uint32_t *level_names;
+} XkbcKeyTypeRec, *XkbcKeyTypePtr;
typedef struct _XkbcSymInterpretRec {
- CARD32 sym;
+ uint32_t sym;
unsigned char flags;
unsigned char match;
- unsigned char mods;
- unsigned char virtual_mod;
- XkbcAnyAction act;
-} XkbcSymInterpretRec,*XkbcSymInterpretPtr;
+ uint8_t mods; /* XXX real or virt? */
+ uint32_t virtual_mod;
+ struct xkb_any_action act;
+} XkbcSymInterpretRec, *XkbcSymInterpretPtr;
typedef struct _XkbcCompatMapRec {
XkbcSymInterpretPtr sym_interpret;
- XkbModsRec groups[XkbNumKbdGroups];
+ XkbcModsRec groups[XkbNumKbdGroups];
unsigned short num_si;
unsigned short size_si;
} XkbcCompatMapRec, *XkbcCompatMapPtr;
typedef struct _XkbcClientMapRec {
unsigned char size_types;
unsigned char num_types;
- XkbKeyTypePtr types;
+ XkbcKeyTypePtr types;
unsigned short size_syms;
unsigned short num_syms;
unsigned char * explicit;
#endif
- XkbcAction *acts;
+ union xkb_action *acts;
XkbBehavior *behaviors;
unsigned short *key_acts;
unsigned char *explicits;
uint32_t *vmodmap;
} XkbcServerMapRec, *XkbcServerMapPtr;
+typedef struct _XkbcNamesRec {
+ uint32_t keycodes;
+ uint32_t geometry;
+ uint32_t symbols;
+ uint32_t types;
+ uint32_t compat;
+ uint32_t vmods[XkbNumVirtualMods];
+ uint32_t indicators[XkbNumIndicators];
+ uint32_t groups[XkbNumKbdGroups];
+ XkbKeyNamePtr keys;
+ XkbKeyAliasPtr key_aliases;
+ uint32_t *radio_groups;
+ uint32_t phys_symbols;
+
+ unsigned char num_keys;
+ unsigned char num_key_aliases;
+ unsigned short num_rg;
+} XkbcNamesRec, *XkbcNamesPtr;
+
+typedef struct _XkbcProperty {
+ char *name;
+ char *value;
+} XkbcPropertyRec, *XkbcPropertyPtr;
+
+typedef struct _XkbcColor {
+ unsigned int pixel;
+ char * spec;
+} XkbcColorRec, *XkbcColorPtr;
+
+typedef struct _XkbcPoint {
+ short x;
+ short y;
+} XkbcPointRec, *XkbcPointPtr;
+
+typedef struct _XkbcBounds {
+ short x1,y1;
+ short x2,y2;
+} XkbcBoundsRec, *XkbcBoundsPtr;
+#define XkbBoundsWidth(b) (((b)->x2)-((b)->x1))
+#define XkbBoundsHeight(b) (((b)->y2)-((b)->y1))
+
+typedef struct _XkbcOutline {
+ unsigned short num_points;
+ unsigned short sz_points;
+ unsigned short corner_radius;
+ XkbcPointPtr points;
+} XkbcOutlineRec, *XkbcOutlinePtr;
+
+typedef struct _XkbcShape {
+ uint32_t name;
+ unsigned short num_outlines;
+ unsigned short sz_outlines;
+ XkbcOutlinePtr outlines;
+ XkbcOutlinePtr approx;
+ XkbcOutlinePtr primary;
+ XkbcBoundsRec bounds;
+} XkbcShapeRec, *XkbcShapePtr;
+#define XkbOutlineIndex(s,o) ((int)((o)-&(s)->outlines[0]))
+
+typedef struct _XkbcShapeDoodad {
+ uint32_t name;
+ unsigned char type;
+ unsigned char priority;
+ short top;
+ short left;
+ short angle;
+ unsigned short color_ndx;
+ unsigned short shape_ndx;
+} XkbcShapeDoodadRec, *XkbcShapeDoodadPtr;
+#define XkbShapeDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
+#define XkbShapeDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
+#define XkbSetShapeDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
+#define XkbSetShapeDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
+
+typedef struct _XkbcTextDoodad {
+ uint32_t name;
+ unsigned char type;
+ unsigned char priority;
+ short top;
+ short left;
+ short angle;
+ short width;
+ short height;
+ unsigned short color_ndx;
+ char * text;
+ char * font;
+} XkbcTextDoodadRec, *XkbcTextDoodadPtr;
+#define XkbTextDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
+#define XkbSetTextDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
+
+typedef struct _XkbcIndicatorDoodad {
+ uint32_t name;
+ unsigned char type;
+ unsigned char priority;
+ short top;
+ short left;
+ short angle;
+ unsigned short shape_ndx;
+ unsigned short on_color_ndx;
+ unsigned short off_color_ndx;
+} XkbcIndicatorDoodadRec, *XkbcIndicatorDoodadPtr;
+#define XkbIndicatorDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
+#define XkbIndicatorDoodadOnColor(g,d) (&(g)->colors[(d)->on_color_ndx])
+#define XkbIndicatorDoodadOffColor(g,d) (&(g)->colors[(d)->off_color_ndx])
+#define XkbSetIndicatorDoodadOnColor(g,d,c) \
+ ((d)->on_color_ndx= (c)-&(g)->colors[0])
+#define XkbSetIndicatorDoodadOffColor(g,d,c) \
+ ((d)->off_color_ndx= (c)-&(g)->colors[0])
+#define XkbSetIndicatorDoodadShape(g,d,s) \
+ ((d)->shape_ndx= (s)-&(g)->shapes[0])
+
+typedef struct _XkbcLogoDoodad {
+ uint32_t name;
+ unsigned char type;
+ unsigned char priority;
+ short top;
+ short left;
+ short angle;
+ unsigned short color_ndx;
+ unsigned short shape_ndx;
+ char * logo_name;
+} XkbcLogoDoodadRec, *XkbcLogoDoodadPtr;
+#define XkbLogoDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
+#define XkbLogoDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
+#define XkbSetLogoDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
+#define XkbSetLogoDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
+
+typedef struct _XkbcAnyDoodad {
+ uint32_t name;
+ unsigned char type;
+ unsigned char priority;
+ short top;
+ short left;
+ short angle;
+} XkbcAnyDoodadRec, *XkbcAnyDoodadPtr;
+
+typedef union _XkbcDoodad {
+ XkbcAnyDoodadRec any;
+ XkbcShapeDoodadRec shape;
+ XkbcTextDoodadRec text;
+ XkbcIndicatorDoodadRec indicator;
+ XkbcLogoDoodadRec logo;
+} XkbcDoodadRec, *XkbcDoodadPtr;
+
+#define XkbUnknownDoodad 0
+#define XkbOutlineDoodad 1
+#define XkbSolidDoodad 2
+#define XkbTextDoodad 3
+#define XkbIndicatorDoodad 4
+#define XkbLogoDoodad 5
+
+typedef struct _XkbcKey {
+ XkbKeyNameRec name;
+ short gap;
+ unsigned char shape_ndx;
+ unsigned char color_ndx;
+} XkbcKeyRec, *XkbcKeyPtr;
+#define XkbKeyShape(g,k) (&(g)->shapes[(k)->shape_ndx])
+#define XkbKeyColor(g,k) (&(g)->colors[(k)->color_ndx])
+#define XkbSetKeyShape(g,k,s) ((k)->shape_ndx= (s)-&(g)->shapes[0])
+#define XkbSetKeyColor(g,k,c) ((k)->color_ndx= (c)-&(g)->colors[0])
+
+typedef struct _XkbRow {
+ short top;
+ short left;
+ unsigned short num_keys;
+ unsigned short sz_keys;
+ int vertical;
+ XkbcKeyPtr keys;
+ XkbcBoundsRec bounds;
+} XkbcRowRec, *XkbcRowPtr;
+
+typedef struct _XkbcSection {
+ uint32_t name;
+ unsigned char priority;
+ short top;
+ short left;
+ unsigned short width;
+ unsigned short height;
+ short angle;
+ unsigned short num_rows;
+ unsigned short num_doodads;
+ unsigned short num_overlays;
+ unsigned short sz_rows;
+ unsigned short sz_doodads;
+ unsigned short sz_overlays;
+ XkbcRowPtr rows;
+ XkbcDoodadPtr doodads;
+ XkbcBoundsRec bounds;
+ struct _XkbOverlay *overlays;
+} XkbcSectionRec, *XkbcSectionPtr;
+
+typedef struct _XkbcOverlayKey {
+ XkbKeyNameRec over;
+ XkbKeyNameRec under;
+} XkbcOverlayKeyRec, *XkbcOverlayKeyPtr;
+
+typedef struct _XkbOverlayRow {
+ unsigned short row_under;
+ unsigned short num_keys;
+ unsigned short sz_keys;
+ XkbcOverlayKeyPtr keys;
+} XkbcOverlayRowRec, *XkbcOverlayRowPtr;
+
+typedef struct _XkbOverlay {
+ uint32_t name;
+ XkbcSectionPtr section_under;
+ unsigned short num_rows;
+ unsigned short sz_rows;
+ XkbcOverlayRowPtr rows;
+ XkbcBoundsPtr bounds;
+} XkbcOverlayRec, *XkbcOverlayPtr;
+
+typedef struct _XkbcGeometry {
+ uint32_t name;
+ unsigned short width_mm;
+ unsigned short height_mm;
+ char * label_font;
+ XkbcColorPtr label_color;
+ XkbcColorPtr base_color;
+ unsigned short sz_properties;
+ unsigned short sz_colors;
+ unsigned short sz_shapes;
+ unsigned short sz_sections;
+ unsigned short sz_doodads;
+ unsigned short sz_key_aliases;
+ unsigned short num_properties;
+ unsigned short num_colors;
+ unsigned short num_shapes;
+ unsigned short num_sections;
+ unsigned short num_doodads;
+ unsigned short num_key_aliases;
+ XkbcPropertyPtr properties;
+ XkbcColorPtr colors;
+ XkbcShapePtr shapes;
+ XkbcSectionPtr sections;
+ XkbcDoodadPtr doodads;
+ XkbKeyAliasPtr key_aliases;
+} XkbcGeometryRec, *XkbcGeometryPtr;
+#define XkbGeomColorIndex(g,c) ((int)((c)-&(g)->colors[0]))
+
+#define XkbGeomPropertiesMask (1<<0)
+#define XkbGeomColorsMask (1<<1)
+#define XkbGeomShapesMask (1<<2)
+#define XkbGeomSectionsMask (1<<3)
+#define XkbGeomDoodadsMask (1<<4)
+#define XkbGeomKeyAliasesMask (1<<5)
+#define XkbGeomAllMask (0x3f)
+
+typedef struct _XkbcGeometrySizes {
+ unsigned int which;
+ unsigned short num_properties;
+ unsigned short num_colors;
+ unsigned short num_shapes;
+ unsigned short num_sections;
+ unsigned short num_doodads;
+ unsigned short num_key_aliases;
+} XkbcGeometrySizesRec, *XkbcGeometrySizesPtr;
+
/* Common keyboard description structure */
typedef struct _XkbcDesc {
unsigned int defined;
XkbcServerMapPtr server;
XkbcClientMapPtr map;
XkbIndicatorPtr indicators;
- XkbNamesPtr names;
- XkbCompatMapPtr compat;
- XkbGeometryPtr geom;
+ XkbcNamesPtr names;
+ XkbcCompatMapPtr compat;
+ XkbcGeometryPtr geom;
} XkbcDescRec, *XkbcDescPtr;
_XFUNCPROTOBEGIN
+typedef uint32_t (*InternAtomFuncPtr)(const char *val);
+typedef const char *(*GetAtomValueFuncPtr)(uint32_t atom);
+
extern void
-XkbcInitAtoms(void);
+XkbcInitAtoms(InternAtomFuncPtr intern, GetAtomValueFuncPtr get_atom_value);
extern XkbcDescPtr
XkbcCompileKeymapFromRules(const XkbRMLVOSet *rmlvo);
* XkbcKeysymToString: if you need to preserve it, then you must
* duplicate it.
*
- * This is CARD32 rather than KeySym, as KeySym changes size between
+ * This is uint32_t rather than KeySym, as KeySym changes size between
* client and server (no, really).
*/
extern char *
-XkbcKeysymToString(CARD32 ks);
+XkbcKeysymToString(uint32_t ks);
/*
* See XkbcKeysymToString comments: this function will accept any string
* from that function.
*/
-extern CARD32
+extern uint32_t
XkbcStringToKeysym(const char *s);
_XFUNCPROTOEND
-#undef KeySym
-#undef Atom
-
#endif /* _XKBCOMMON_H_ */