* Dan Nicholson <dbn.lists@gmail.com>
*/
-#ifndef MAP_H
-#define MAP_H
+#ifndef KEYMAP_H
+#define KEYMAP_H
/* Don't use compat names in internal code. */
#define _XKBCOMMON_COMPAT_H
ACTION_TYPE_SWITCH_VT,
ACTION_TYPE_CTRL_SET,
ACTION_TYPE_CTRL_LOCK,
- ACTION_TYPE_KEY_REDIRECT,
ACTION_TYPE_PRIVATE,
_ACTION_TYPE_NUM_ENTRIES
};
ACTION_ABSOLUTE_SWITCH = (1 << 5),
ACTION_ABSOLUTE_X = (1 << 6),
ACTION_ABSOLUTE_Y = (1 << 7),
- ACTION_NO_ACCEL = (1 << 8),
+ ACTION_ACCEL = (1 << 8),
ACTION_SAME_SCREEN = (1 << 9),
};
};
enum xkb_match_operation {
- MATCH_NONE = 0,
- MATCH_ANY_OR_NONE = 1,
- MATCH_ANY = 2,
- MATCH_ALL = 3,
- MATCH_EXACTLY = 4,
- MATCH_OP_MASK = \
- (MATCH_NONE | MATCH_ANY_OR_NONE | MATCH_ANY | MATCH_ALL | \
- MATCH_EXACTLY),
- MATCH_LEVEL_ONE_ONLY = (1 << 7),
+ MATCH_NONE,
+ MATCH_ANY_OR_NONE,
+ MATCH_ANY,
+ MATCH_ALL,
+ MATCH_EXACTLY,
};
struct xkb_mods {
int8_t screen;
};
-struct xkb_redirect_key_action {
- enum xkb_action_type type;
- enum xkb_action_flags flags;
- xkb_keycode_t new_kc;
- uint8_t mods_mask;
- uint8_t mods;
- uint16_t vmods_mask;
- uint16_t vmods;
-};
-
struct xkb_pointer_action {
enum xkb_action_type type;
enum xkb_action_flags flags;
enum xkb_action_type type;
enum xkb_action_flags flags;
uint8_t count;
- int8_t button;
+ uint8_t button;
};
struct xkb_private_action {
enum xkb_action_type type;
- enum xkb_action_flags flags;
uint8_t data[7];
};
struct xkb_controls_action ctrls;
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;
struct xkb_pointer_button_action btn;
struct xkb_private_action priv;
};
-struct xkb_kt_map_entry {
+struct xkb_key_type_entry {
xkb_level_index_t level;
struct xkb_mods mods;
struct xkb_mods preserve;
};
struct xkb_key_type {
+ xkb_atom_t name;
struct xkb_mods mods;
xkb_level_index_t num_levels;
- struct xkb_kt_map_entry *map;
- unsigned int num_entries;
- xkb_atom_t name;
+ unsigned int num_level_names;
xkb_atom_t *level_names;
+ unsigned int num_entries;
+ struct xkb_key_type_entry *entries;
};
struct xkb_sym_interpret {
xkb_keysym_t sym;
- bool repeat;
enum xkb_match_operation match;
xkb_mod_mask_t mods;
xkb_mod_index_t virtual_mod;
- union xkb_action act;
+ union xkb_action action;
+ bool level_one_only;
+ bool repeat;
};
-struct xkb_indicator_map {
+struct xkb_led {
xkb_atom_t name;
enum xkb_state_component which_groups;
xkb_layout_mask_t groups;
/* Such an awkward name. Oh well. */
enum xkb_range_exceed_type {
+ RANGE_WRAP = 0,
RANGE_SATURATE,
- RANGE_WRAP,
RANGE_REDIRECT,
};
bool explicit_type;
/* Points to a type in keymap->types. */
const struct xkb_key_type *type;
- /* Use XkbKeyGroupWidth for the number of levels. */
+ /* Use XkbKeyNumLevels for the number of levels. */
struct xkb_level *levels;
};
struct xkb_group *groups;
};
-typedef darray(xkb_atom_t) darray_xkb_atom_t;
-
struct xkb_mod {
xkb_atom_t name;
enum mod_type type;
xkb_mod_mask_t mapping; /* vmod -> real mod mapping */
};
+struct xkb_mod_set {
+ struct xkb_mod mods[XKB_MAX_MODS];
+ unsigned int num_mods;
+};
+
/* Common keyboard description structure */
struct xkb_keymap {
struct xkb_context *ctx;
struct xkb_key *keys;
/* aliases in no particular order */
- darray(struct xkb_key_alias) key_aliases;
+ unsigned int num_key_aliases;
+ struct xkb_key_alias *key_aliases;
struct xkb_key_type *types;
unsigned int num_types;
- darray(struct xkb_sym_interpret) sym_interpret;
+ unsigned int num_sym_interprets;
+ struct xkb_sym_interpret *sym_interprets;
- darray(struct xkb_mod) mods;
+ struct xkb_mod_set mods;
/* Number of groups in the key with the most groups. */
xkb_layout_index_t num_groups;
- darray_xkb_atom_t group_names;
+ /* Not all groups must have names. */
+ xkb_layout_index_t num_group_names;
+ xkb_atom_t *group_names;
- darray(struct xkb_indicator_map) indicators;
+ struct xkb_led leds[XKB_MAX_LEDS];
+ unsigned int num_leds;
char *keycodes_section_name;
char *symbols_section_name;
char *compat_section_name;
};
+#define xkb_keys_foreach(iter, keymap) \
+ for ((iter) = (keymap)->keys + (keymap)->min_key_code; \
+ (iter) <= (keymap)->keys + (keymap)->max_key_code; \
+ (iter)++)
+
+#define xkb_mods_foreach(iter, mods_) \
+ for ((iter) = (mods_)->mods; \
+ (iter) < (mods_)->mods + (mods_)->num_mods; \
+ (iter)++)
+
+#define xkb_mods_enumerate(idx, iter, mods_) \
+ for ((idx) = 0, (iter) = (mods_)->mods; \
+ (idx) < (mods_)->num_mods; \
+ (idx)++, (iter)++)
+
+#define xkb_leds_foreach(iter, keymap) \
+ for ((iter) = (keymap)->leds; \
+ (iter) < (keymap)->leds + (keymap)->num_leds; \
+ (iter)++)
+
+#define xkb_leds_enumerate(idx, iter, keymap) \
+ for ((idx) = 0, (iter) = (keymap)->leds; \
+ (idx) < (keymap)->num_leds; \
+ (idx)++, (iter)++)
+
static inline const struct xkb_key *
XkbKey(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
return &keymap->keys[kc];
}
-#define xkb_foreach_key(iter, keymap) \
- for (iter = keymap->keys + keymap->min_key_code; \
- iter <= keymap->keys + keymap->max_key_code; \
- iter++)
-
static inline xkb_level_index_t
-XkbKeyGroupWidth(const struct xkb_key *key, xkb_layout_index_t layout)
+XkbKeyNumLevels(const struct xkb_key *key, xkb_layout_index_t layout)
{
return key->groups[layout].type->num_levels;
}
+/*
+ * If the virtual modifiers are not bound to anything, the entry
+ * is not active and should be skipped. xserver does this with
+ * cached entry->active field.
+ */
+static inline bool
+entry_is_active(const struct xkb_key_type_entry *entry)
+{
+ return entry->mods.mods == 0 || entry->mods.mask != 0;
+}
+
struct xkb_keymap *
xkb_keymap_new(struct xkb_context *ctx,
enum xkb_keymap_format format,
- enum xkb_keymap_compile_flags);
+ enum xkb_keymap_compile_flags flags);
+
+struct xkb_key *
+XkbKeyByName(struct xkb_keymap *keymap, xkb_atom_t name, bool use_aliases);
+
+xkb_atom_t
+XkbResolveKeyAlias(const struct xkb_keymap *keymap, xkb_atom_t name);
+
+void
+XkbEscapeMapName(char *name);
+
+xkb_mod_index_t
+XkbModNameToIndex(const struct xkb_mod_set *mods, xkb_atom_t name,
+ enum mod_type type);
+
+bool
+XkbLevelsSameSyms(const struct xkb_level *a, const struct xkb_level *b);
+
+xkb_layout_index_t
+XkbWrapGroupIntoRange(int32_t group,
+ xkb_layout_index_t num_groups,
+ enum xkb_range_exceed_type out_of_range_group_action,
+ xkb_layout_index_t out_of_range_group_number);
+
+xkb_mod_mask_t
+mod_mask_get_effective(struct xkb_keymap *keymap, xkb_mod_mask_t mods);
+
+struct xkb_keymap_format_ops {
+ bool (*keymap_new_from_names)(struct xkb_keymap *keymap,
+ const struct xkb_rule_names *names);
+ bool (*keymap_new_from_string)(struct xkb_keymap *keymap,
+ const char *string, size_t length);
+ bool (*keymap_new_from_file)(struct xkb_keymap *keymap, FILE *file);
+ char *(*keymap_get_as_string)(struct xkb_keymap *keymap);
+};
+
+extern const struct xkb_keymap_format_ops text_v1_keymap_format_ops;
#endif