get_mod_mask_text(keymap, 0, key->vmodmap));
}
- switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(keymap, kc))) {
+ switch (key->out_of_range_group_action) {
case XkbClampIntoRange:
write_buf(keymap, buf, size, offset, "\n\t\t\tgroupsClamp,");
break;
case XkbRedirectIntoRange:
write_buf(keymap, buf, size, offset,
"\n\t\t\tgroupsRedirect= Group%d,",
- XkbOutOfRangeGroupNumber(XkbKeyGroupInfo(keymap,
- kc)) + 1);
+ key->out_of_range_group_number + 1);
break;
}
_X_EXPORT xkb_group_index_t
xkb_key_num_groups(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
- return XkbKeyNumGroups(keymap, kc);
+ if (XkbKeycodeInRange(keymap, kc))
+ return XkbKey(keymap, kc)->num_groups;
+ return 0;
}
/**
xkb_key_get_group(struct xkb_state *state, xkb_keycode_t kc)
{
struct xkb_keymap *keymap = xkb_state_get_map(state);
- unsigned int info = XkbKeyGroupInfo(keymap, kc);
- unsigned int num_groups = XkbKeyNumGroups(keymap, kc);
unsigned int ret = xkb_state_serialize_group(state, XKB_STATE_EFFECTIVE);
+ struct xkb_key *key = XkbKey(keymap, kc);
- if (ret < XkbKeyNumGroups(keymap, kc))
+ if (ret < key->num_groups)
return ret;
- switch (XkbOutOfRangeGroupAction(info)) {
+ switch (key->out_of_range_group_action) {
case XkbRedirectIntoRange:
- ret = XkbOutOfRangeGroupNumber(info);
- if (ret >= num_groups)
+ ret = key->out_of_range_group_number;
+ if (ret >= key->num_groups)
ret = 0;
break;
case XkbClampIntoRange:
- ret = num_groups - 1;
+ ret = key->num_groups - 1;
break;
case XkbWrapIntoRange:
default:
- ret %= num_groups;
+ ret %= key->num_groups;
break;
}
const xkb_keysym_t **syms_out)
{
int num_syms;
+ struct xkb_key *key = XkbKey(keymap, kc);
- if (group >= XkbKeyNumGroups(keymap, kc))
+ if (group >= key->num_groups)
goto err;
if (level >= XkbKeyGroupWidth(keymap, kc, group))
goto err;
size_t acts_index;
unsigned char kt_index[XkbNumKbdGroups];
- unsigned char group_info;
+
+ unsigned int num_groups;
+ /* How many levels the largest group has. */
unsigned char width;
+ uint8_t out_of_range_group_action;
+ uint8_t out_of_range_group_number;
+
/* per level/group index into 'syms' */
int *sym_index;
/* per level/group */
}
static inline unsigned char
-XkbNumGroups(unsigned char group_info)
-{
- return group_info & 0x0f;
-}
-
-static inline unsigned char
-XkbOutOfRangeGroupInfo(unsigned char group_info)
-{
- return group_info & 0xf0;
-}
-
-static inline unsigned char
-XkbOutOfRangeGroupAction(unsigned char group_info)
-{
- return group_info & 0xc0;
-}
-
-static inline unsigned char
-XkbOutOfRangeGroupNumber(unsigned char group_info)
-{
- return (group_info & 0x30) >> 4;
-}
-
-static inline unsigned char
-XkbSetGroupInfo(unsigned char group_info,
- unsigned char out_of_range_group_action,
- unsigned char out_of_range_group_number)
-{
- return
- (out_of_range_group_action & 0xc0) |
- ((out_of_range_group_number & 3) << 4) |
- (XkbNumGroups(group_info));
-}
-
-static inline unsigned char
-XkbSetNumGroups(unsigned char group_info, unsigned char num_groups)
-{
- return (group_info & 0xf0) | (num_groups & 0x0f);
-}
-
-static inline unsigned char
-XkbKeyGroupInfo(struct xkb_keymap *keymap, xkb_keycode_t kc)
-{
- return XkbKey(keymap, kc)->group_info;
-}
-
-static inline unsigned char
-XkbKeyNumGroups(struct xkb_keymap *keymap, xkb_keycode_t kc)
-{
- return XkbNumGroups(XkbKeyGroupInfo(keymap, kc));
-}
-
-static inline unsigned char
XkbKeyTypeIndex(struct xkb_keymap *keymap, xkb_keycode_t kc,
unsigned int group)
{
static inline unsigned char
XkbKeyNumActions(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
+ struct xkb_key *key = XkbKey(keymap, kc);
if (XkbKeyHasActions(keymap, kc))
- return XkbKeyGroupsWidth(keymap, kc) * XkbKeyNumGroups(keymap, kc);
+ return key->width * key->num_groups;
return 1;
}
for (i = 0; i < INTERP_SIZE; i++)
interps[i] = NULL;
- for (group = 0; group < XkbKeyNumGroups(keymap, kc); group++) {
+ for (group = 0; group < key->num_groups; group++) {
for (level = 0; level < XkbKeyGroupWidth(keymap, kc, group);
level++) {
i = (group * width) + level;
}
if (num_acts)
- num_acts = XkbKeyNumGroups(keymap, kc) * width;
+ num_acts = key->num_groups * width;
acts = XkbcResizeKeyActions(keymap, kc, num_acts);
if (num_acts && !acts)
return false;
- for (group = 0; group < XkbKeyNumGroups(keymap, kc); group++) {
+ for (group = 0; group < key->num_groups; group++) {
for (level = 0; level < XkbKeyGroupWidth(keymap, kc, group);
level++) {
struct xkb_sym_interpret *interp;
typedef struct _KeyInfo {
CommonInfo defs;
unsigned long name; /* the 4 chars of the key name, as long */
- unsigned char groupInfo;
unsigned char typesDefined;
unsigned char symsDefined;
unsigned char actsDefined;
struct xkb_behavior behavior;
unsigned short vmodmap;
xkb_atom_t dfltType;
+
+ uint8_t out_of_range_group_action;
+ uint8_t out_of_range_group_number;
} KeyInfo;
/**
keyi->defs.merge = MERGE_OVERRIDE;
keyi->defs.next = NULL;
keyi->name = KeyNameToLong(dflt);
- keyi->groupInfo = 0;
keyi->typesDefined = keyi->symsDefined = keyi->actsDefined = 0;
for (i = 0; i < XkbNumKbdGroups; i++) {
keyi->behavior.data = 0;
keyi->vmodmap = 0;
keyi->repeat = RepeatUndefined;
+ keyi->out_of_range_group_action = 0;
+ keyi->out_of_range_group_number = 0;
}
-/**
- * Free memory associated with this key keyi and reset to sane values.
- */
static void
FreeKeyInfo(KeyInfo *keyi)
{
int i;
- keyi->defs.defined = 0;
- keyi->defs.file_id = 0;
- keyi->defs.merge = MERGE_OVERRIDE;
- keyi->defs.next = NULL;
- keyi->groupkeyi = 0;
- keyi->typesDefined = keyi->symsDefined = keyi->actsDefined = 0;
for (i = 0; i < XkbNumKbdGroups; i++) {
- keyi->numLevels[i] = 0;
- keyi->types[i] = XKB_ATOM_NONE;
darray_free(keyi->syms[i]);
darray_free(keyi->symsMapIndex[i]);
darray_free(keyi->symsMapNumEntries[i]);
darray_free(keyi->acts[i]);
}
- keyi->dfltType = XKB_ATOM_NONE;
- keyi->behavior.type = XkbKB_Default;
- keyi->behavior.data = 0;
- keyi->vmodmap = 0;
- keyi->repeat = RepeatUndefined;
}
/**
KeyInfo *keyi;
free(info->name);
- darray_foreach(keyi, info->keys)
+ darray_foreach(keyi, info->keys) {
FreeKeyInfo(keyi);
+ }
darray_free(info->keys);
if (info->modMap)
ClearCommonInfo(&info->modMap->defs);
into->defs.defined |= _Key_Type_Dflt;
}
if (UseNewField(_Key_GroupInfo, &into->defs, &from->defs, &collide)) {
- into->groupInfo = from->groupInfo;
+ into->out_of_range_group_action = from->out_of_range_group_action;
+ into->out_of_range_group_number = from->out_of_range_group_number;
into->defs.defined |= _Key_GroupInfo;
}
if (collide) {
return false;
}
if (tmp.uval)
- keyi->groupInfo = XkbWrapIntoRange;
+ keyi->out_of_range_group_action = XkbWrapIntoRange;
else
- keyi->groupInfo = XkbClampIntoRange;
+ keyi->out_of_range_group_action = XkbClampIntoRange;
keyi->defs.defined |= _Key_GroupInfo;
}
else if ((strcasecmp(field, "groupsclamp") == 0) ||
return false;
}
if (tmp.uval)
- keyi->groupInfo = XkbClampIntoRange;
+ keyi->out_of_range_group_action = XkbClampIntoRange;
else
- keyi->groupInfo = XkbWrapIntoRange;
+ keyi->out_of_range_group_action = XkbWrapIntoRange;
keyi->defs.defined |= _Key_GroupInfo;
}
else if ((strcasecmp(field, "groupsredirect") == 0) ||
ACTION("Definition with non-integer group ignored\n");
return false;
}
- keyi->groupInfo =
- XkbSetGroupInfo(0, XkbRedirectIntoRange, tmp.uval - 1);
+ keyi->out_of_range_group_action = XkbRedirectIntoRange;
+ keyi->out_of_range_group_number = tmp.uval - 1;
keyi->defs.defined |= _Key_GroupInfo;
}
else {
xkb_keycode_t *kc_rtrn)
{
xkb_keycode_t kc;
+ struct xkb_key *key;
unsigned int group, level, min_group = UINT_MAX, min_level = UINT_MAX;
for (kc = keymap->min_key_code; kc <= keymap->max_key_code; kc++) {
- for (group = 0; group < XkbKeyNumGroups(keymap, kc); group++) {
+ key = XkbKey(keymap, kc);
+
+ for (group = 0; group < key->num_groups; group++) {
for (level = 0; level < XkbKeyGroupWidth(keymap, kc, group);
level++) {
if (XkbKeyNumSyms(keymap, kc, group, level) != 1 ||
else
outActs = NULL;
- if (keyi->defs.defined & _Key_GroupInfo)
- i = keyi->groupInfo;
- else
- i = key->group_info;
-
- key->group_info = XkbSetNumGroups(i, nGroups);
+ key->num_groups = nGroups;
+ if (keyi->defs.defined & _Key_GroupInfo) {
+ key->out_of_range_group_number = keyi->out_of_range_group_number;
+ key->out_of_range_group_action = keyi->out_of_range_group_action;
+ }
key->width = width;
- key->sym_index = uTypedCalloc(nGroups * width, int);
- key->num_syms = uTypedCalloc(nGroups * width, unsigned int);
+ key->sym_index = calloc(nGroups * width, sizeof(*key->sym_index));
+ key->num_syms = calloc(nGroups * width, sizeof(*key->num_syms));
for (i = 0; i < nGroups; i++) {
/* assign kt_index[i] to the index of the type in map->types.
if (key->name[0] == '\0')
continue;
- if (XkbKeyNumGroups(keymap, kc) < 1)
+ if (key->num_groups < 1)
WARN("No symbols defined for <%.4s> (keycode %d)\n",
key->name, kc);
}