diff --git a/src/keymap-dump.c b/src/keymap-dump.c index 2c19d9e..5b8f66a 100644 --- a/src/keymap-dump.c +++ b/src/keymap-dump.c @@ -346,6 +346,7 @@ write_types(struct xkb_keymap *keymap, struct buf *buf) { int n; struct xkb_key_type *type; + struct xkb_kt_map_entry *entry; if (keymap->types_section_name) write_buf(buf, "\txkb_types \"%s\" {\n\n", @@ -362,8 +363,7 @@ write_types(struct xkb_keymap *keymap, struct buf *buf) get_mod_mask_text(keymap, type->mods.real_mods, type->mods.vmods)); - for (n = 0; n < darray_size(type->map); n++) { - struct xkb_kt_map_entry *entry = &darray_item(type->map, n); + darray_foreach(entry, type->map) { char *str; str = get_mod_mask_text(keymap, entry->mods.real_mods, @@ -371,13 +371,13 @@ write_types(struct xkb_keymap *keymap, struct buf *buf) write_buf(buf, "\t\t\tmap[%s]= Level%d;\n", str, entry->level + 1); - if (!type->preserve || (!type->preserve[n].real_mods && - !type->preserve[n].vmods)) + if (!entry->preserve.real_mods && !entry->preserve.vmods) continue; + write_buf(buf, "\t\t\tpreserve[%s]= ", str); write_buf(buf, "%s;\n", - get_mod_mask_text(keymap, type->preserve[n].real_mods, - type->preserve[n].vmods)); + get_mod_mask_text(keymap, entry->preserve.real_mods, + entry->preserve.vmods)); } if (type->level_names) { diff --git a/src/xkb-priv.h b/src/xkb-priv.h index 9541013..256faf9 100644 --- a/src/xkb-priv.h +++ b/src/xkb-priv.h @@ -244,13 +244,13 @@ struct xkb_mods { struct xkb_kt_map_entry { xkb_level_index_t level; struct xkb_mods mods; + struct xkb_mods preserve; }; struct xkb_key_type { struct xkb_mods mods; xkb_level_index_t num_levels; darray(struct xkb_kt_map_entry) map; - struct xkb_mods *preserve; const char *name; const char **level_names; }; diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c index f25a1f5..a41df54 100644 --- a/src/xkbcomp/keytypes.c +++ b/src/xkbcomp/keytypes.c @@ -126,7 +126,6 @@ typedef struct _PreserveInfo { struct list entry; - int matchingMapIndex; xkb_mod_mask_t indexMods; xkb_mod_mask_t preMods; xkb_mod_mask_t indexVMods; @@ -564,7 +563,6 @@ AddPreserve(KeyTypesInfo *info, KeyTypeInfo *type, } *old = *new; - old->matchingMapIndex = -1; list_append(&old->entry, &type->preserves); return true; @@ -1054,7 +1052,9 @@ CopyDefToKeyType(KeyTypesInfo *info, KeyTypeInfo *def, return false; } - pre->matchingMapIndex = match - &darray_item(def->entries, 0); + match->preserve.mask = pre->preMods; + match->preserve.real_mods = pre->preMods; + match->preserve.vmods = pre->preVMods; } type->mods.real_mods = def->mask; @@ -1062,28 +1062,6 @@ CopyDefToKeyType(KeyTypesInfo *info, KeyTypeInfo *def, type->num_levels = def->num_levels; memcpy(&type->map, &def->entries, sizeof(def->entries)); - if (!list_empty(&def->preserves)) { - type->preserve = calloc(darray_size(type->map), - sizeof(*type->preserve)); - if (!type->preserve) { - log_warn(info->keymap->ctx, - "Couldn't allocate preserve array; " - "Preserve setting for type %s lost\n", - xkb_atom_text(keymap->ctx, def->name)); - } - else { - list_foreach(pre, &def->preserves, entry) { - int ndx = pre->matchingMapIndex; - type->preserve[ndx].mask = pre->preMods; - type->preserve[ndx].real_mods = pre->preMods; - type->preserve[ndx].vmods = pre->preVMods; - } - } - } - else { - type->preserve = NULL; - } - type->name = xkb_atom_text(keymap->ctx, def->name); if (!darray_empty(def->level_names)) { diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c index 748a51e..3ca1d89 100644 --- a/src/xkbcomp/xkbcomp.c +++ b/src/xkbcomp/xkbcomp.c @@ -355,7 +355,6 @@ xkb_map_unref(struct xkb_keymap *keymap) darray_foreach(type, keymap->types) { darray_free(type->map); - free(type->preserve); free(type->level_names); } darray_free(keymap->types);