/***====================================================================***/
typedef struct _ModMapEntry {
- struct list entry;
enum merge_mode merge;
bool haveSymbol;
int modifier;
VModInfo vmods;
ActionsInfo *actions;
xkb_atom_t groupNames[XKB_NUM_GROUPS];
-
- struct list modMaps;
+ darray(ModMapEntry) modMaps;
struct xkb_keymap *keymap;
} SymbolsInfo;
info->merge = MERGE_OVERRIDE;
darray_init(info->keys);
darray_growalloc(info->keys, 110);
- list_init(&info->modMaps);
+ darray_init(info->modMaps);
for (i = 0; i < XKB_NUM_GROUPS; i++)
info->groupNames[i] = XKB_ATOM_NONE;
InitKeyInfo(&info->dflt, file_id);
ClearSymbolsInfo(SymbolsInfo * info)
{
KeyInfo *keyi;
- ModMapEntry *mm, *next;
free(info->name);
darray_foreach(keyi, info->keys)
ClearKeyInfo(keyi);
darray_free(info->keys);
- list_foreach_safe(mm, next, &info->modMaps, entry)
- free(mm);
+ darray_free(info->modMaps);
memset(info, 0, sizeof(SymbolsInfo));
}
bool clobber;
clobber = (new->merge != MERGE_AUGMENT);
- list_foreach(mm, &info->modMaps, entry) {
+ darray_foreach(mm, info->modMaps) {
if (new->haveSymbol && mm->haveSymbol
&& (new->u.keySym == mm->u.keySym)) {
unsigned use, ignore;
}
}
- mm = malloc(sizeof(*mm));
- if (!mm) {
- log_wsgo(info->keymap->ctx,
- "Could not allocate modifier map entry; "
- "Modifier map for %s will be incomplete\n",
- ModIndexText(new->modifier));
- return false;
- }
-
- *mm = *new;
- list_add(&mm->entry, &info->modMaps);
+ darray_append(info->modMaps, *new);
return true;
}
{
unsigned int i;
KeyInfo *keyi;
- ModMapEntry *mm, *next;
+ ModMapEntry *mm;
if (from->errorCount > 0) {
into->errorCount += from->errorCount;
}
darray_foreach(keyi, from->keys) {
- if (merge != MERGE_DEFAULT)
- keyi->merge = merge;
-
+ merge = (merge == MERGE_DEFAULT ? keyi->merge : merge);
if (!AddKeySymbols(into, keyi))
into->errorCount++;
}
- list_foreach_safe(mm, next, &from->modMaps, entry) {
- if (merge != MERGE_DEFAULT)
- mm->merge = merge;
+ darray_foreach(mm, from->modMaps) {
+ mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge);
if (!AddModMapEntry(into, mm))
into->errorCount++;
- free(mm);
}
- list_init(&from->modMaps);
}
static void
}
}
- list_foreach(mm, &info.modMaps, entry)
+ darray_foreach(mm, info.modMaps)
if (!CopyModMapDef(&info, mm))
info.errorCount++;