Get rid of xkb_indicator Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
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]);