Commit ed082617689515af170f8a590e0074786b6a7b86

Ran Benita 2012-07-15T00:39:15

Get rid of xkb_compat_map Same as xkb_{client,server}_map which were already removed. Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/alloc.c b/src/alloc.c
index 8b8fb2b..09e2d41 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -146,39 +146,6 @@ free_sym_maps(struct xkb_keymap *keymap)
 }
 
 int
-XkbcAllocCompatMap(struct xkb_keymap *keymap, unsigned nSI)
-{
-    if (!keymap)
-        return BadMatch;
-
-    if (!keymap->compat) {
-        keymap->compat = calloc(1, sizeof(*keymap->compat));
-        if (!keymap->compat)
-            return BadAlloc;
-        darray_init(keymap->compat->sym_interpret);
-    }
-
-    darray_growalloc(keymap->compat->sym_interpret, nSI);
-    darray_resize(keymap->compat->sym_interpret, 0);
-
-    memset(keymap->compat->groups, 0,
-           XkbNumKbdGroups * sizeof(*keymap->compat->groups));
-
-    return Success;
-}
-
-static void
-XkbcFreeCompatMap(struct xkb_keymap *keymap)
-{
-    if (!keymap || !keymap->compat)
-        return;
-
-    darray_free(keymap->compat->sym_interpret);
-    free(keymap->compat);
-    keymap->compat = NULL;
-}
-
-int
 XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
                size_t nTotalAliases)
 {
@@ -337,7 +304,7 @@ XkbcFreeKeyboard(struct xkb_keymap *keymap)
     darray_free(keymap->acts);
     free(keymap->behaviors);
     free(keymap->vmodmap);
-    XkbcFreeCompatMap(keymap);
+    darray_free(keymap->sym_interpret);
     XkbcFreeIndicatorMaps(keymap);
     XkbcFreeNames(keymap);
     XkbcFreeControls(keymap);
diff --git a/src/alloc.h b/src/alloc.h
index a933929..df9844a 100644
--- a/src/alloc.h
+++ b/src/alloc.h
@@ -30,9 +30,6 @@
 #include "xkb-priv.h"
 
 extern int
-XkbcAllocCompatMap(struct xkb_keymap *keymap, unsigned nSI);
-
-extern int
 XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
                size_t nTotalAliases);
 
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 8443e7d..735c6ef 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -679,7 +679,7 @@ write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
     write_buf(keymap, buf, size, offset, "\t\tinterpret.repeat= False;\n");
     write_buf(keymap, buf, size, offset, "\t\tinterpret.locking= False;\n");
 
-    darray_foreach(interp, keymap->compat->sym_interpret) {
+    darray_foreach(interp, keymap->sym_interpret) {
         char keysym_name[64];
 
         if (interp->sym == XKB_KEY_NoSymbol)
@@ -714,7 +714,7 @@ write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
     for (i = 0; i < XkbNumKbdGroups; i++) {
         struct xkb_mods *gc;
 
-        gc = &keymap->compat->groups[i];
+        gc = &keymap->groups[i];
         if (gc->real_mods == 0 && gc->vmods == 0)
             continue;
         write_buf(keymap, buf, size, offset,
diff --git a/src/map.c b/src/map.c
index a3dc648..cb36c72 100644
--- a/src/map.c
+++ b/src/map.c
@@ -146,7 +146,7 @@ xkb_map_num_groups(struct xkb_keymap *keymap)
     xkb_group_index_t i;
 
     for (i = 0; i < XkbNumKbdGroups; i++)
-        if (keymap->compat->groups[i].mask)
+        if (keymap->groups[i].mask)
             ret++;
 
     return ret;
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 2072010..bd6ed34 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -261,11 +261,6 @@ struct xkb_sym_interpret {
     union xkb_action act;
 };
 
-struct xkb_compat_map {
-    darray(struct xkb_sym_interpret) sym_interpret;
-    struct xkb_mods groups[XkbNumKbdGroups];
-};
-
 struct xkb_sym_map {
     unsigned char kt_index[XkbNumKbdGroups];
     unsigned char group_info;
@@ -346,15 +341,17 @@ struct xkb_keymap {
     struct xkb_controls *      ctrls;
     struct xkb_indicator *     indicators;
     struct xkb_names *        names;
-    struct xkb_compat_map *    compat;
 
     /* key -> explicit flags mapping */
     unsigned char *explicit;
 
     darray(struct xkb_key_type) types;
 
+    /* key -> symbols mapping */
     darray(struct xkb_sym_map) key_sym_map;
 
+    darray(struct xkb_sym_interpret) sym_interpret;
+
     /* key -> mod mapping */
     unsigned char *modmap;
     /* vmod -> mod mapping */
@@ -362,10 +359,13 @@ struct xkb_keymap {
     /* key -> vmod mapping */
     uint32_t *vmodmap;
 
-    /* acts[key_acts[keycode]] */
+    struct xkb_mods groups[XkbNumKbdGroups];
+
+    /* key -> actions mapping: acts[key_acts[keycode]] */
     darray(union xkb_action) acts;
-    darray(size_t ) key_acts;
+    darray(size_t) key_acts;
 
+    /* key -> behavior mapping */
     struct xkb_behavior *behaviors;
 };
 
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index c9cf637..9b820bf 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -705,8 +705,8 @@ HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap,
 }
 
 static void
-CopyInterps(CompatInfo * info,
-            struct xkb_compat_map * compat, bool needSymbol, unsigned pred)
+CopyInterps(CompatInfo *info, struct xkb_keymap *keymap,
+            bool needSymbol, unsigned pred)
 {
     SymInterpInfo *si;
 
@@ -715,7 +715,7 @@ CopyInterps(CompatInfo * info,
             (needSymbol && (si->interp.sym == XKB_KEY_NoSymbol)) ||
             ((!needSymbol) && (si->interp.sym != XKB_KEY_NoSymbol)))
             continue;
-        darray_append(compat->sym_interpret, si->interp);
+        darray_append(keymap->sym_interpret, si->interp);
     }
 }
 
@@ -736,10 +736,8 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
     if (info.errorCount != 0)
         goto err_info;
 
-    if (XkbcAllocCompatMap(keymap, info.nInterps) != Success) {
-        WSGO("Couldn't allocate compatibility map\n");
-        goto err_info;
-    }
+    darray_init(keymap->sym_interpret);
+    darray_growalloc(keymap->sym_interpret, info.nInterps);
 
     if (info.name) {
         if (XkbcAllocNames(keymap, 0, 0) != Success)
@@ -748,23 +746,22 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
     }
 
     if (info.nInterps > 0) {
-        CopyInterps(&info, keymap->compat, true, XkbSI_Exactly);
-        CopyInterps(&info, keymap->compat, true, XkbSI_AllOf | XkbSI_NoneOf);
-        CopyInterps(&info, keymap->compat, true, XkbSI_AnyOf);
-        CopyInterps(&info, keymap->compat, true, XkbSI_AnyOfOrNone);
-        CopyInterps(&info, keymap->compat, false, XkbSI_Exactly);
-        CopyInterps(&info, keymap->compat, false, XkbSI_AllOf | XkbSI_NoneOf);
-        CopyInterps(&info, keymap->compat, false, XkbSI_AnyOf);
-        CopyInterps(&info, keymap->compat, false, XkbSI_AnyOfOrNone);
+        CopyInterps(&info, keymap, true, XkbSI_Exactly);
+        CopyInterps(&info, keymap, true, XkbSI_AllOf | XkbSI_NoneOf);
+        CopyInterps(&info, keymap, true, XkbSI_AnyOf);
+        CopyInterps(&info, keymap, true, XkbSI_AnyOfOrNone);
+        CopyInterps(&info, keymap, false, XkbSI_Exactly);
+        CopyInterps(&info, keymap, false, XkbSI_AllOf | XkbSI_NoneOf);
+        CopyInterps(&info, keymap, false, XkbSI_AnyOf);
+        CopyInterps(&info, keymap, false, XkbSI_AnyOfOrNone);
     }
 
-    for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups; i++,
-         gcm++) {
-        if ((gcm->file_id != 0) || (gcm->real_mods != 0) ||
-            (gcm->vmods != 0)) {
-            keymap->compat->groups[i].mask = gcm->real_mods;
-            keymap->compat->groups[i].real_mods = gcm->real_mods;
-            keymap->compat->groups[i].vmods = gcm->vmods;
+    for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups;
+         i++, gcm++) {
+        if (gcm->file_id != 0 || gcm->real_mods != 0 || gcm->vmods != 0) {
+            keymap->groups[i].mask = gcm->real_mods;
+            keymap->groups[i].real_mods = gcm->real_mods;
+            keymap->groups[i].vmods = gcm->vmods;
         }
     }
 
@@ -844,7 +841,7 @@ FindInterpForKey(struct xkb_keymap *keymap, xkb_keycode_t key,
     if (num_syms == 0)
         return NULL;
 
-    darray_foreach(interp, keymap->compat->sym_interpret) {
+    darray_foreach(interp, keymap->sym_interpret) {
         uint32_t mods;
         bool found;
 
@@ -1026,7 +1023,7 @@ UpdateModifiersFromCompat(struct xkb_keymap *keymap)
 
     /* Update group modifiers. */
     for (i = 0; i < XkbNumKbdGroups; i++) {
-        struct xkb_mods *group = &keymap->compat->groups[i];
+        struct xkb_mods *group = &keymap->groups[i];
         group->mask = group->real_mods | VModsToReal(keymap, group->vmods);
     }