Commit 50fef8eb8a5994a1fa61531cc8217ce071ac617f

Ran Benita 2012-07-15T00:46:31

Get rid of xkb_indicator Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/alloc.c b/src/alloc.c
index 09e2d41..08f8813 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -251,30 +251,6 @@ XkbcFreeControls(struct xkb_keymap *keymap)
     }
 }
 
-int
-XkbcAllocIndicatorMaps(struct xkb_keymap *keymap)
-{
-    if (!keymap)
-        return BadMatch;
-
-    if (!keymap->indicators) {
-        keymap->indicators = uTypedCalloc(1, struct xkb_indicator);
-        if (!keymap->indicators)
-            return BadAlloc;
-    }
-
-    return Success;
-}
-
-static void
-XkbcFreeIndicatorMaps(struct xkb_keymap *keymap)
-{
-    if (keymap) {
-        free(keymap->indicators);
-        keymap->indicators = NULL;
-    }
-}
-
 struct xkb_keymap *
 XkbcAllocKeyboard(struct xkb_context *ctx)
 {
@@ -305,7 +281,6 @@ XkbcFreeKeyboard(struct xkb_keymap *keymap)
     free(keymap->behaviors);
     free(keymap->vmodmap);
     darray_free(keymap->sym_interpret);
-    XkbcFreeIndicatorMaps(keymap);
     XkbcFreeNames(keymap);
     XkbcFreeControls(keymap);
     xkb_context_unref(keymap->ctx);
diff --git a/src/alloc.h b/src/alloc.h
index df9844a..b1ee0d4 100644
--- a/src/alloc.h
+++ b/src/alloc.h
@@ -36,9 +36,6 @@ XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
 extern int
 XkbcAllocControls(struct xkb_keymap *keymap);
 
-extern int
-XkbcAllocIndicatorMaps(struct xkb_keymap *keymap);
-
 extern struct xkb_keymap *
 XkbcAllocKeyboard(struct xkb_context *ctx);
 
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 735c6ef..e321220 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -409,7 +409,7 @@ static bool
 write_indicator_map(struct xkb_keymap *keymap, char **buf, size_t *size,
                     size_t *offset, int num)
 {
-    struct xkb_indicator_map *led = &keymap->indicators->maps[num];
+    struct xkb_indicator_map *led = &keymap->indicators[num];
 
     write_buf(keymap, buf, size, offset, "\t\tindicator \"%s\" {\n",
               keymap->names->indicators[num]);
@@ -723,7 +723,7 @@ write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
     }
 
     for (i = 0; i < XkbNumIndicators; i++) {
-        struct xkb_indicator_map *map = &keymap->indicators->maps[i];
+        struct xkb_indicator_map *map = &keymap->indicators[i];
         if (map->flags == 0 && map->which_groups == 0 &&
             map->groups == 0 && map->which_mods == 0 &&
             map->mods.real_mods == 0 && map->mods.vmods == 0 &&
diff --git a/src/map.c b/src/map.c
index cb36c72..0190647 100644
--- a/src/map.c
+++ b/src/map.c
@@ -200,9 +200,9 @@ xkb_map_num_leds(struct xkb_keymap *keymap)
     xkb_led_index_t i;
 
     for (i = 0; i < XkbNumIndicators; i++)
-        if (keymap->indicators->maps[i].which_groups ||
-            keymap->indicators->maps[i].which_mods ||
-            keymap->indicators->maps[i].ctrls)
+        if (keymap->indicators[i].which_groups ||
+            keymap->indicators[i].which_mods ||
+            keymap->indicators[i].ctrls)
             ret++;
 
     return ret;
diff --git a/src/state.c b/src/state.c
index ffb45bc..4174383 100644
--- a/src/state.c
+++ b/src/state.c
@@ -530,7 +530,7 @@ xkb_state_led_update_all(struct xkb_state *state)
     state->leds = 0;
 
     for (led = 0; led < XkbNumIndicators; led++) {
-        struct xkb_indicator_map *map = &state->keymap->indicators->maps[led];
+        struct xkb_indicator_map *map = &state->keymap->indicators[led];
         uint32_t mod_mask = 0;
         uint32_t group_mask = 0;
 
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index bd6ed34..6d39358 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -284,10 +284,6 @@ struct xkb_indicator_map {
     unsigned int ctrls;
 };
 
-struct xkb_indicator {
-    struct xkb_indicator_map maps[XkbNumIndicators];
-};
-
 struct xkb_key_name {
     char name[XkbKeyNameLength];
 };
@@ -339,7 +335,6 @@ struct xkb_keymap {
     xkb_keycode_t max_key_code;
 
     struct xkb_controls *      ctrls;
-    struct xkb_indicator *     indicators;
     struct xkb_names *        names;
 
     /* key -> explicit flags mapping */
@@ -367,6 +362,8 @@ struct xkb_keymap {
 
     /* key -> behavior mapping */
     struct xkb_behavior *behaviors;
+
+    struct xkb_indicator_map indicators[XkbNumIndicators];
 };
 
 #define XkbNumGroups(g)             ((g) & 0x0f)
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 9b820bf..2fd83a3 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -1029,7 +1029,7 @@ UpdateModifiersFromCompat(struct xkb_keymap *keymap)
 
     /* Update vmod -> indicator maps. */
     for (i = 0; i < XkbNumIndicators; i++) {
-        struct xkb_mods *led = &keymap->indicators->maps[i].mods;
+        struct xkb_mods *led = &keymap->indicators[i].mods;
         led->mask = led->real_mods | VModsToReal(keymap, led->vmods);
     }
 
diff --git a/src/xkbcomp/indicators.c b/src/xkbcomp/indicators.c
index bcbded6..d6e40f7 100644
--- a/src/xkbcomp/indicators.c
+++ b/src/xkbcomp/indicators.c
@@ -393,7 +393,7 @@ BindIndicators(struct xkb_keymap *keymap, LEDInfo *unbound)
             }
             else {
                 struct xkb_indicator_map * map;
-                map = &keymap->indicators->maps[led->indicator - 1];
+                map = &keymap->indicators[led->indicator - 1];
                 map->flags = led->flags;
                 map->which_groups = led->which_groups;
                 map->groups = led->groups;
@@ -428,11 +428,7 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
         WSGO("Couldn't allocate names\n");
         ACTION("Indicator names may be incorrect\n");
     }
-    if (XkbcAllocIndicatorMaps(keymap) != Success) {
-        WSGO("Can't allocate indicator maps\n");
-        ACTION("Indicator map definitions may be lost\n");
-        return false;
-    }
+
     for (led = leds; led != NULL; led = next) {
         next = (LEDInfo *) led->defs.next;
         if ((led->groups != 0) && (led->which_groups == 0))
@@ -449,7 +445,7 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
         }
         else {
             struct xkb_indicator_map * im;
-            im = &keymap->indicators->maps[led->indicator - 1];
+            im = &keymap->indicators[led->indicator - 1];
             im->flags = led->flags;
             im->which_groups = led->which_groups;
             im->groups = led->groups;
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index 1ec1138..b6c9f59 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -769,10 +769,6 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
 
     if (info.leds) {
         IndicatorNameInfo *ii;
-        if (XkbcAllocIndicatorMaps(keymap) != Success) {
-            WSGO("Couldn't allocate IndicatorRec in CompileKeycodes\n");
-            ACTION("Physical indicators not set\n");
-        }
 
         for (ii = info.leds; ii; ii = (IndicatorNameInfo *) ii->defs.next) {
             free(keymap->names->indicators[ii->ndx - 1]);