Remove XkbKeyTypeIndex and widen index type

We don't need the macro, and using char for the kt_index is imaginably
too small.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-08-10 22:06:12 +03:00
parent 87dff888ab
commit 600caac33a
2 changed files with 8 additions and 16 deletions

View File

@ -677,12 +677,12 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf)
if (key->explicit & XkbExplicitKeyTypesMask) { if (key->explicit & XkbExplicitKeyTypesMask) {
bool multi_type = false; bool multi_type = false;
int type = XkbKeyTypeIndex(key, 0); struct xkb_key_type *type = XkbKeyType(keymap, key, 0);
simple = false; simple = false;
for (group = 0; group < key->num_groups; group++) { for (group = 1; group < key->num_groups; group++) {
if (XkbKeyTypeIndex(key, group) != type) { if (XkbKeyType(keymap, key, group) != type) {
multi_type = true; multi_type = true;
break; break;
} }
@ -692,17 +692,15 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf)
for (group = 0; group < key->num_groups; group++) { for (group = 0; group < key->num_groups; group++) {
if (!(key->explicit & (1 << group))) if (!(key->explicit & (1 << group)))
continue; continue;
type = XkbKeyTypeIndex(key, group); type = XkbKeyType(keymap, key, group);
write_buf(buf, "\n\t\t\ttype[group%u]= \"%s\",", write_buf(buf, "\n\t\t\ttype[group%u]= \"%s\",",
group + 1, group + 1,
xkb_atom_text(keymap->ctx, xkb_atom_text(keymap->ctx, type->name));
keymap->types[type].name));
} }
} }
else { else {
write_buf(buf, "\n\t\t\ttype= \"%s\",", write_buf(buf, "\n\t\t\ttype= \"%s\",",
xkb_atom_text(keymap->ctx, xkb_atom_text(keymap->ctx, type->name));
keymap->types[type].name));
} }
} }

View File

@ -323,7 +323,7 @@ struct xkb_key {
union xkb_action *actions; union xkb_action *actions;
unsigned char kt_index[XkbNumKbdGroups]; unsigned kt_index[XkbNumKbdGroups];
xkb_group_index_t num_groups; xkb_group_index_t num_groups;
/* How many levels the largest group has. */ /* How many levels the largest group has. */
@ -396,17 +396,11 @@ XkbKeyGetKeycode(struct xkb_keymap *keymap, struct xkb_key *key)
#define xkb_foreach_key(iter, keymap) \ #define xkb_foreach_key(iter, keymap) \
xkb_foreach_key_from(iter, keymap, keymap->min_key_code) xkb_foreach_key_from(iter, keymap, keymap->min_key_code)
static inline unsigned char
XkbKeyTypeIndex(struct xkb_key *key, xkb_group_index_t group)
{
return key->kt_index[group & 0x3];
}
static inline struct xkb_key_type * static inline struct xkb_key_type *
XkbKeyType(struct xkb_keymap *keymap, struct xkb_key *key, XkbKeyType(struct xkb_keymap *keymap, struct xkb_key *key,
xkb_group_index_t group) xkb_group_index_t group)
{ {
return &keymap->types[XkbKeyTypeIndex(key, group)]; return &keymap->types[key->kt_index[group]];
} }
static inline xkb_level_index_t static inline xkb_level_index_t