Get rid of struct xkb_sym_map Past its usefulness; put the stuff directly in xkb_key. 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 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
diff --git a/src/alloc.c b/src/alloc.c
index 97ca82b..0c329e2 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -66,14 +66,6 @@ XkbcCopyKeyType(const struct xkb_key_type *from, struct xkb_key_type *into)
return Success;
}
-bool
-XkbcResizeKeySyms(struct xkb_keymap *keymap, xkb_keycode_t kc,
- unsigned int needed)
-{
- darray_resize0(XkbKey(keymap, kc)->sym_map.syms, needed);
- return true;
-}
-
union xkb_action *
XkbcResizeKeyActions(struct xkb_keymap *keymap, xkb_keycode_t kc,
uint32_t needed)
@@ -135,15 +127,17 @@ free_types(struct xkb_keymap *keymap)
}
static void
-free_sym_maps(struct xkb_keymap *keymap)
+free_keys(struct xkb_keymap *keymap)
{
struct xkb_key *key;
darray_foreach(key, keymap->keys) {
- free(key->sym_map.sym_index);
- free(key->sym_map.num_syms);
- darray_free(key->sym_map.syms);
+ free(key->sym_index);
+ free(key->num_syms);
+ darray_free(key->syms);
}
+
+ darray_free(keymap->keys);
}
static void
@@ -190,11 +184,10 @@ XkbcFreeKeyboard(struct xkb_keymap *keymap)
return;
free_types(keymap);
- free_sym_maps(keymap);
darray_free(keymap->acts);
darray_free(keymap->sym_interpret);
free_names(keymap);
- darray_free(keymap->keys);
+ free_keys(keymap);
xkb_context_unref(keymap->ctx);
free(keymap);
}
diff --git a/src/alloc.h b/src/alloc.h
index bfdde56..7da3447 100644
--- a/src/alloc.h
+++ b/src/alloc.h
@@ -38,10 +38,6 @@ XkbcFreeKeyboard(struct xkb_keymap *keymap);
extern int
XkbcCopyKeyType(const struct xkb_key_type *from, struct xkb_key_type *into);
-extern bool
-XkbcResizeKeySyms(struct xkb_keymap *keymap, xkb_keycode_t kc,
- uint32_t needed);
-
extern union xkb_action *
XkbcResizeKeyActions(struct xkb_keymap *keymap, xkb_keycode_t kc,
uint32_t needed);
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 4b0fcc2..28be176 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -261,15 +261,6 @@ struct xkb_sym_interpret {
union xkb_action act;
};
-struct xkb_sym_map {
- unsigned char kt_index[XkbNumKbdGroups];
- unsigned char group_info;
- unsigned char width;
- int *sym_index; /* per level/group index into 'syms' */
- unsigned int *num_syms; /* per level/group */
- darray(xkb_keysym_t) syms;
-};
-
struct xkb_behavior {
unsigned char type;
unsigned char data;
@@ -307,14 +298,28 @@ struct xkb_controls {
struct xkb_key {
char name[XkbKeyNameLength];
+
unsigned char explicit;
- struct xkb_sym_map sym_map;
+
unsigned char modmap;
uint32_t vmodmap;
+
struct xkb_behavior behavior;
+
bool repeats;
+
/* Index into keymap->acts */
size_t acts_index;
+
+ unsigned char kt_index[XkbNumKbdGroups];
+ unsigned char group_info;
+ unsigned char width;
+
+ /* per level/group index into 'syms' */
+ int *sym_index;
+ /* per level/group */
+ unsigned int *num_syms;
+ darray(xkb_keysym_t) syms;
};
/* Common keyboard description structure */
@@ -406,7 +411,7 @@ XkbSetNumGroups(unsigned char group_info, unsigned char num_groups)
static inline unsigned char
XkbKeyGroupInfo(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
- return XkbKey(keymap, kc)->sym_map.group_info;
+ return XkbKey(keymap, kc)->group_info;
}
static inline unsigned char
@@ -419,7 +424,7 @@ static inline unsigned char
XkbKeyTypeIndex(struct xkb_keymap *keymap, xkb_keycode_t kc,
unsigned int group)
{
- return XkbKey(keymap, kc)->sym_map.kt_index[group & 0x3];
+ return XkbKey(keymap, kc)->kt_index[group & 0x3];
}
static inline struct xkb_key_type *
@@ -438,7 +443,7 @@ XkbKeyGroupWidth(struct xkb_keymap *keymap, xkb_keycode_t kc,
static inline unsigned char
XkbKeyGroupsWidth(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
- return XkbKey(keymap, kc)->sym_map.width;
+ return XkbKey(keymap, kc)->width;
}
static inline unsigned int
@@ -446,13 +451,13 @@ XkbKeyNumSyms(struct xkb_keymap *keymap, xkb_keycode_t kc,
unsigned int group, unsigned int level)
{
unsigned char width = XkbKeyGroupsWidth(keymap, kc);
- return XkbKey(keymap, kc)->sym_map.num_syms[group * width + level];
+ return XkbKey(keymap, kc)->num_syms[group * width + level];
}
static inline xkb_keysym_t *
XkbKeySym(struct xkb_keymap *keymap, xkb_keycode_t kc, int ndx)
{
- return &darray_item(XkbKey(keymap, kc)->sym_map.syms, ndx);
+ return &darray_item(XkbKey(keymap, kc)->syms, ndx);
}
static inline int
@@ -460,7 +465,7 @@ XkbKeySymOffset(struct xkb_keymap *keymap, xkb_keycode_t kc,
unsigned group, unsigned int level)
{
unsigned char width = XkbKeyGroupsWidth(keymap, kc);
- return XkbKey(keymap, kc)->sym_map.sym_index[group * width + level];
+ return XkbKey(keymap, kc)->sym_index[group * width + level];
}
static inline xkb_keysym_t *
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index eede0c5..b3fda43 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1701,7 +1701,6 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *keyi, int start_from)
unsigned types[XkbNumKbdGroups];
union xkb_action *outActs;
unsigned int symIndex = 0;
- struct xkb_sym_map *sym_map;
useAlias = (start_from == 0);
@@ -1774,11 +1773,8 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *keyi, int start_from)
sizeSyms += darray_size(keyi->syms[i]);
}
- if (!XkbcResizeKeySyms(keymap, kc, sizeSyms)) {
- WSGO("Could not enlarge symbols for %s (keycode %d)\n",
- longText(keyi->name), kc);
- return false;
- }
+ darray_resize0(key->syms, sizeSyms);
+
if (haveActions) {
outActs = XkbcResizeKeyActions(keymap, kc, width * nGroups);
if (outActs == NULL) {
@@ -1791,17 +1787,15 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *keyi, int start_from)
else
outActs = NULL;
- sym_map = &key->sym_map;
-
if (keyi->defs.defined & _Key_GroupInfo)
i = keyi->groupInfo;
else
- i = sym_map->group_info;
+ i = key->group_info;
- sym_map->group_info = XkbSetNumGroups(i, nGroups);
- sym_map->width = width;
- sym_map->sym_index = uTypedCalloc(nGroups * width, int);
- sym_map->num_syms = uTypedCalloc(nGroups * width, unsigned int);
+ key->group_info = XkbSetNumGroups(i, nGroups);
+ key->width = width;
+ key->sym_index = uTypedCalloc(nGroups * width, int);
+ key->num_syms = uTypedCalloc(nGroups * width, unsigned int);
for (i = 0; i < nGroups; i++) {
/* assign kt_index[i] to the index of the type in map->types.
@@ -1812,25 +1806,25 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *keyi, int start_from)
* FIXME: There should be a better fix for this.
*/
if (keyi->numLevels[i])
- sym_map->kt_index[i] = types[i];
+ key->kt_index[i] = types[i];
if (!darray_empty(keyi->syms[i])) {
/* fill key to "width" symbols*/
for (tmp = 0; tmp < width; tmp++) {
if (tmp < keyi->numLevels[i] &&
darray_item(keyi->symsMapNumEntries[i], tmp) != 0) {
- memcpy(darray_mem(sym_map->syms, symIndex),
+ memcpy(darray_mem(key->syms, symIndex),
darray_mem(keyi->syms[i],
darray_item(keyi->symsMapIndex[i], tmp)),
darray_item(keyi->symsMapNumEntries[i],
tmp) * sizeof(xkb_keysym_t));
- sym_map->sym_index[(i * width) + tmp] = symIndex;
- sym_map->num_syms[(i * width) + tmp] =
+ key->sym_index[(i * width) + tmp] = symIndex;
+ key->num_syms[(i * width) + tmp] =
darray_item(keyi->symsMapNumEntries[i], tmp);
- symIndex += sym_map->num_syms[(i * width) + tmp];
+ symIndex += key->num_syms[(i * width) + tmp];
}
else {
- sym_map->sym_index[(i * width) + tmp] = -1;
- sym_map->num_syms[(i * width) + tmp] = 0;
+ key->sym_index[(i * width) + tmp] = -1;
+ key->num_syms[(i * width) + tmp] = 0;
}
if (outActs != NULL && !darray_empty(keyi->acts[i])) {
if (tmp < keyi->numLevels[i])