unsigned fileID;
unsigned merge;
unsigned explicit_group;
- unsigned groupInfo;
darray(KeyInfo) keys;
KeyInfo dflt;
VModInfo vmods;
info->errorCount = 0;
info->fileID = 0;
info->merge = MergeOverride;
- info->groupInfo = 0;
darray_init(info->keys);
darray_growalloc(info->keys, SYMBOLS_INIT_SIZE);
info->modMap = NULL;
return true;
}
+enum key_group_selector {
+ NONE = 0,
+ FROM = (1 << 0),
+ TO = (1 << 1),
+};
+
static bool
MergeKeyGroups(SymbolsInfo * info,
KeyInfo * into, KeyInfo * from, unsigned group)
{
xkb_keysym_t *resultSyms = NULL;
+ enum key_group_selector using = NONE;
union xkb_action *resultActs;
unsigned int resultWidth;
unsigned int resultSize = 0;
if (into->symsMapNumEntries[group] && (i < into->numLevels[group]))
toSize = into->symsMapNumEntries[group][i];
- if (fromSize == 0 || fromSize == toSize || clobber)
+ if (fromSize == 0)
{
- fromSize += toSize;
+ resultSize += toSize;
+ using |= TO;
}
- else if (toSize == 0)
+ else if (toSize == 0 || clobber)
{
resultSize += fromSize;
+ using |= FROM;
+ }
+ else
+ {
+ resultSize += toSize;
+ using |= TO;
}
}
if (resultSize == 0)
goto out;
+ if (using == FROM)
+ {
+ resultSyms = from->syms[group];
+ goto out;
+ }
+ else if (using == TO)
+ {
+ resultSyms = into->syms[group];
+ goto out;
+ }
+
resultSyms = uTypedCalloc(resultSize, xkb_keysym_t);
if (!resultSyms)
{
for (i = 0; i < resultWidth; i++)
{
- enum { NONE, FROM, TO } use;
+ enum key_group_selector use = NONE;
unsigned int fromSize = 0;
unsigned int toSize = 0;
- if (from->symsMapNumEntries[group] && (i < from->numLevels[group]))
+ if (i < from->numLevels[group])
fromSize = from->symsMapNumEntries[group][i];
- if (into->symsMapNumEntries[group] && (i < into->numLevels[group]))
+ if (i < into->numLevels[group])
toSize = into->symsMapNumEntries[group][i];
- if (!fromSize && !toSize)
+ if (fromSize == 0 && toSize == 0)
{
into->symsMapIndex[group][i] = -1;
into->symsMapNumEntries[group][i] = 0;
continue;
}
- if ((fromSize && !toSize) || clobber)
+ if (fromSize == 0)
+ use = TO;
+ else if (toSize == 0 || clobber)
use = FROM;
else
use = TO;
else
{
memcpy(&resultSyms[cur_idx],
- &into->syms[group][from->symsMapIndex[group][i]],
+ &into->syms[group][into->symsMapIndex[group][i]],
into->symsMapNumEntries[group][i] * sizeof(xkb_keysym_t));
into->symsMapIndex[group][i] = cur_idx;
}
if (resultActs != from->acts[group])
free(from->acts[group]);
into->numLevels[group] = resultWidth;
- free(into->syms[group]);
+ if (resultSyms != into->syms[group])
+ free(into->syms[group]);
into->syms[group] = resultSyms;
- free(from->syms[group]);
+ if (resultSyms != from->syms[group])
+ free(from->syms[group]);
from->syms[group] = NULL;
from->sizeSyms[group] = 0;
into->sizeSyms[group] = resultSize;
from->symsMapNumEntries[group] = NULL;
into->acts[group] = resultActs;
from->acts[group] = NULL;
- into->symsDefined |= (1 << group);
+ if (into->syms[group])
+ into->symsDefined |= (1 << group);
from->symsDefined &= ~(1 << group);
into->actsDefined |= (1 << group);
from->actsDefined &= ~(1 << group);
key->symsMapNumEntries[ndx][i] = 0;
break;
}
+ if (key->symsMapNumEntries[ndx][i] == 1 &&
+ key->syms[ndx][key->symsMapIndex[ndx][i] + j] == XKB_KEY_NoSymbol) {
+ key->symsMapIndex[ndx][i] = -1;
+ key->symsMapNumEntries[ndx][i] = 0;
+ }
}
}
for (j = key->numLevels[ndx] - 1;
static int
HandleSymbolsVar(VarDef *stmt, struct xkb_keymap *keymap, SymbolsInfo *info)
{
- ExprResult elem, field, tmp;
+ ExprResult elem, field;
ExprDef *arrayNdx;
bool ret;
&& ((strcasecmp(field.str, "groupswrap") == 0) ||
(strcasecmp(field.str, "wrapgroups") == 0)))
{
- if (!ExprResolveBoolean(keymap->ctx, stmt->value, &tmp))
- {
- ERROR("Illegal setting for global groupsWrap\n");
- ACTION("Non-boolean value ignored\n");
- ret = false;
- }
- else {
- if (tmp.uval)
- info->groupInfo = XkbWrapIntoRange;
- else
- info->groupInfo = XkbClampIntoRange;
- ret = true;
- }
+ ERROR("Global \"groupswrap\" not supported\n");
+ ACTION("Ignored\n");
+ ret = true;
}
else if ((elem.str == NULL)
&& ((strcasecmp(field.str, "groupsclamp") == 0) ||
(strcasecmp(field.str, "clampgroups") == 0)))
{
- if (!ExprResolveBoolean(keymap->ctx, stmt->value, &tmp))
- {
- ERROR("Illegal setting for global groupsClamp\n");
- ACTION("Non-boolean value ignored\n");
- return false;
- }
- else {
- if (tmp.uval)
- info->groupInfo = XkbClampIntoRange;
- else
- info->groupInfo = XkbWrapIntoRange;
- ret = true;
- }
+ ERROR("Global \"groupsclamp\" not supported\n");
+ ACTION("Ignored\n");
+ ret = true;
}
else if ((elem.str == NULL)
&& ((strcasecmp(field.str, "groupsredirect") == 0) ||
(strcasecmp(field.str, "redirectgroups") == 0)))
{
- if (!ExprResolveGroup(keymap->ctx, stmt->value, &tmp))
- {
- ERROR("Illegal group index for global groupsRedirect\n");
- ACTION("Definition with non-integer group ignored\n");
- ret = false;
- }
- else {
- info->groupInfo = XkbSetGroupInfo(0, XkbRedirectIntoRange,
- tmp.uval);
- ret = true;
- }
+ ERROR("Global \"groupsredirect\" not supported\n");
+ ACTION("Ignored\n");
+ ret = true;
}
else if ((elem.str == NULL) && (strcasecmp(field.str, "allownone") == 0))
{
ERROR("Radio groups not supported\n");
- ACTION("Ignoring \"allow none\" specification\n");
- ret = false;
+ ACTION("Ignoring \"allownone\" specification\n");
+ ret = true;
}
else {
ret = SetActionField(keymap, elem.str, field.str, arrayNdx,
identical = false;
break;
}
- if ((key->symsMapIndex[i] != key->symsMapIndex[i]) &&
+ if ((key->symsMapIndex[i] != key->symsMapIndex[0]) &&
(key->symsMapIndex[i] == NULL || key->symsMapIndex[0] == NULL ||
memcmp(key->symsMapIndex[i], key->symsMapIndex[0],
key->numLevels[0] * sizeof(int))))
identical = false;
continue;
}
- if ((key->symsMapNumEntries[i] != key->symsMapNumEntries[i]) &&
+ if ((key->symsMapNumEntries[i] != key->symsMapNumEntries[0]) &&
(key->symsMapNumEntries[i] == NULL ||
key->symsMapNumEntries[0] == NULL ||
memcmp(key->symsMapNumEntries[i], key->symsMapNumEntries[0],
unsigned types[XkbNumKbdGroups];
union xkb_action *outActs;
unsigned int symIndex = 0;
+ struct xkb_sym_map *sym_map;
useAlias = (start_from == 0);
}
else
outActs = NULL;
+
+ sym_map = &darray_item(keymap->map->key_sym_map, kc);
+
if (key->defs.defined & _Key_GroupInfo)
i = key->groupInfo;
else
- i = keymap->map->key_sym_map[kc].group_info;
-
- keymap->map->key_sym_map[kc].group_info = XkbSetNumGroups(i, nGroups);
- keymap->map->key_sym_map[kc].width = width;
- keymap->map->key_sym_map[kc].sym_index = uTypedCalloc(nGroups * width,
- int);
- keymap->map->key_sym_map[kc].num_syms = uTypedCalloc(nGroups * width,
- unsigned int);
+ i = sym_map->group_info;
+
+ sym_map->group_info = XkbSetNumGroups(i, nGroups);
+ sym_map->width = width;
+ sym_map->sym_index = uTypedCalloc(nGroups * width, int);
+ sym_map->num_syms = uTypedCalloc(nGroups * width, unsigned int);
+
for (i = 0; i < nGroups; i++)
{
/* assign kt_index[i] to the index of the type in map->types.
* FIXME: There should be a better fix for this.
*/
if (key->numLevels[i])
- keymap->map->key_sym_map[kc].kt_index[i] = types[i];
+ sym_map->kt_index[i] = types[i];
if (key->sizeSyms[i] != 0)
{
/* fill key to "width" symbols*/
{
if (tmp < key->numLevels[i] && key->symsMapNumEntries[i][tmp])
{
- memcpy(&keymap->map->key_sym_map[kc].syms[symIndex],
+ memcpy(&sym_map->syms[symIndex],
&key->syms[i][key->symsMapIndex[i][tmp]],
key->symsMapNumEntries[i][tmp] *
sizeof(xkb_keysym_t));
- keymap->map->key_sym_map[kc].sym_index[(i * width) + tmp] =
- symIndex;
- keymap->map->key_sym_map[kc].num_syms[(i * width) + tmp] =
+ sym_map->sym_index[(i * width) + tmp] = symIndex;
+ sym_map->num_syms[(i * width) + tmp] =
key->symsMapNumEntries[i][tmp];
- symIndex +=
- keymap->map->key_sym_map[kc].num_syms[(i * width) + tmp];
+ symIndex += sym_map->num_syms[(i * width) + tmp];
}
else
{
- keymap->map->key_sym_map[kc].sym_index[(i * width) + tmp] = -1;
- keymap->map->key_sym_map[kc].num_syms[(i * width) + tmp] = 0;
+ sym_map->sym_index[(i * width) + tmp] = -1;
+ sym_map->num_syms[(i * width) + tmp] = 0;
}
if ((outActs != NULL) && (key->acts[i] != NULL))
{
for (i = 0; i < XkbNumKbdGroups; i++) {
if (info.groupNames[i] != XKB_ATOM_NONE) {
- free(UNCONSTIFY(keymap->names->groups[i]));
+ free(keymap->names->groups[i]);
keymap->names->groups[i] = xkb_atom_strdup(keymap->ctx,
info.groupNames[i]);
}