summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-07-15 13:15:33 +0300
committerRan Benita <ran234@gmail.com>2012-07-18 12:46:28 +0300
commit4066fcc9b5e395aa53a8d9a9a73466ba29c80c7a (patch)
tree756cc844411361813cde2657b8515c958255eaf0
parent7d9f031341672f0df4fcc12a3066400326a5395f (diff)
downloadxorg-lib-libxkbcommon-4066fcc9b5e395aa53a8d9a9a73466ba29c80c7a.tar.gz
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>
-rw-r--r--src/alloc.c21
-rw-r--r--src/alloc.h4
-rw-r--r--src/xkb-priv.h37
-rw-r--r--src/xkbcomp/symbols.c34
4 files changed, 42 insertions, 54 deletions
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])