From 0bb24c2d2322b2ccd79eddf90137d7feaf7f3a6f Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 9 Mar 2012 19:03:59 +0000 Subject: [PATCH] Introduce xkb_keysym_t type Signed-off-by: Daniel Stone --- include/xkbcommon/xkbcommon.h | 9 +++++---- src/keysym.c | 8 ++++---- src/malloc.c | 16 ++++++++-------- src/misc.c | 2 +- src/text.c | 2 +- src/xkballoc.h | 2 +- src/xkbcomp/expr.c | 2 +- src/xkbcomp/parseutils.c | 4 ++-- src/xkbcomp/parseutils.h | 2 +- src/xkbcomp/symbols.c | 30 +++++++++++++++--------------- src/xkbmisc.h | 4 ++-- 11 files changed, 41 insertions(+), 40 deletions(-) diff --git a/include/xkbcommon/xkbcommon.h b/include/xkbcommon/xkbcommon.h index fcc9b62..6e5cfdc 100644 --- a/include/xkbcommon/xkbcommon.h +++ b/include/xkbcommon/xkbcommon.h @@ -61,6 +61,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include typedef uint32_t xkb_keycode_t; +typedef uint32_t xkb_keysym_t; #define XKB_KEYCODE_MAX (0xffffffff - 1) #define xkb_keycode_is_legal_ext(kc) (kc <= XKB_KEYCODE_MAX) @@ -227,7 +228,7 @@ struct xkb_key_type { }; struct xkb_sym_interpret { - uint32_t sym; + xkb_keysym_t sym; unsigned char flags; unsigned char match; uint8_t mods; /* XXX real or virt? */ @@ -263,7 +264,7 @@ struct xkb_client_map { uint32_t size_syms; uint32_t num_syms; - uint32_t *syms; + xkb_keysym_t *syms; struct xkb_sym_map * key_sym_map; unsigned char *modmap; @@ -576,13 +577,13 @@ xkb_canonicalise_components(struct xkb_component_names * names, * client and server (no, really). */ _X_EXPORT extern void -xkb_keysym_to_string(uint32_t ks, char *buffer, size_t size); +xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size); /* * See xkb_keysym_to_string comments: this function will accept any string * from that function. */ -_X_EXPORT extern uint32_t +_X_EXPORT extern xkb_keysym_t xkb_string_to_keysym(const char *s); _XFUNCPROTOEND diff --git a/src/keysym.c b/src/keysym.c index 0eab240..24fdf52 100644 --- a/src/keysym.c +++ b/src/keysym.c @@ -38,7 +38,7 @@ authorization from the authors. #include "ks_tables.h" void -xkb_keysym_to_string(uint32_t ks, char *buffer, size_t size) +xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size) { int i, n, h, idx; const unsigned char *entry; @@ -91,7 +91,7 @@ xkb_keysym_to_string(uint32_t ks, char *buffer, size_t size) snprintf(buffer, size, "0x%08x", ks); } -uint32_t +xkb_keysym_t xkb_string_to_keysym(const char *s) { int i, n, h, c, idx; @@ -99,7 +99,7 @@ xkb_string_to_keysym(const char *s) const char *p = s; const unsigned char *entry; unsigned char sig1, sig2; - uint32_t val; + xkb_keysym_t val; while ((c = *p++)) sig = (sig << 1) + c; @@ -150,7 +150,7 @@ xkb_string_to_keysym(const char *s) * no separating underscore, while some XF86* syms in the latter did. * As a last ditch effort, try without. */ if (strncmp(s, "XF86_", 5) == 0) { - uint32_t ret; + xkb_keysym_t ret; char *tmp = strdup(s); if (!tmp) return NoSymbol; diff --git a/src/malloc.c b/src/malloc.c index 1f830e6..40f0f7b 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -85,7 +85,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes) if (!map->syms) { map->size_syms = (nKeys * 15) / 10; - map->syms = _XkbTypedCalloc(map->size_syms, uint32_t); + map->syms = _XkbTypedCalloc(map->size_syms, xkb_keysym_t); if (!map->syms) { map->size_syms = 0; return BadAlloc; @@ -257,13 +257,13 @@ XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into) return Success; } -uint32_t * +xkb_keysym_t * XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key, unsigned int needed) { uint32_t i, nSyms, nKeySyms; uint32_t nOldSyms; - uint32_t *newSyms; + xkb_keysym_t *newSyms; if (needed == 0) { xkb->map->key_sym_map[key].offset = 0; @@ -277,11 +277,11 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key, if (xkb->map->size_syms - xkb->map->num_syms >= needed) { if (nOldSyms > 0) memcpy(&xkb->map->syms[xkb->map->num_syms], - XkbKeySymsPtr(xkb, key), nOldSyms * sizeof(uint32_t)); + XkbKeySymsPtr(xkb, key), nOldSyms * sizeof(xkb_keysym_t)); if ((needed - nOldSyms) > 0) memset(&xkb->map->syms[xkb->map->num_syms + XkbKeyNumSyms(xkb, key)], - 0, (needed - nOldSyms) * sizeof(uint32_t)); + 0, (needed - nOldSyms) * sizeof(xkb_keysym_t)); xkb->map->key_sym_map[key].offset = xkb->map->num_syms; xkb->map->num_syms += needed; @@ -290,7 +290,7 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key, } xkb->map->size_syms += (needed > 32 ? needed : 32); - newSyms = _XkbTypedCalloc(xkb->map->size_syms, uint32_t); + newSyms = _XkbTypedCalloc(xkb->map->size_syms, xkb_keysym_t); if (!newSyms) return NULL; @@ -307,10 +307,10 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key, nKeySyms = needed; if (nCopy != 0) memcpy(&newSyms[nSyms], XkbKeySymsPtr(xkb, i), - nCopy * sizeof(uint32_t)); + nCopy * sizeof(xkb_keysym_t)); if (nKeySyms > nCopy) memset(&newSyms[nSyms + nCopy], 0, - (nKeySyms - nCopy) * sizeof(uint32_t)); + (nKeySyms - nCopy) * sizeof(xkb_keysym_t)); xkb->map->key_sym_map[i].offset = nSyms; nSyms += nKeySyms; diff --git a/src/misc.c b/src/misc.c index 4a8fd2c..8e49e02 100644 --- a/src/misc.c +++ b/src/misc.c @@ -189,7 +189,7 @@ XkbcEnsureSafeMapName(char *name) } unsigned -_XkbcKSCheckCase(uint32_t ks) +_XkbcKSCheckCase(xkb_keysym_t ks) { unsigned set = (ks & (~0xff)) >> 8; unsigned rtrn = 0; diff --git a/src/text.c b/src/text.c index 15421f9..1ed5f7d 100644 --- a/src/text.c +++ b/src/text.c @@ -253,7 +253,7 @@ XkbcActionTypeText(unsigned type) } const char * -XkbcKeysymText(uint32_t sym) +XkbcKeysymText(xkb_keysym_t sym) { static char buffer[16]; diff --git a/src/xkballoc.h b/src/xkballoc.h index 4d36e5a..f5f3919 100644 --- a/src/xkballoc.h +++ b/src/xkballoc.h @@ -60,7 +60,7 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions); extern int XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type *into); -extern uint32_t * +extern xkb_keysym_t * XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key, uint32_t needed); extern union xkb_action * diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index 2f6fb6d..db45e9b 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -1019,7 +1019,7 @@ ExprResolveKeySym(ExprDef * expr, ExprResult * val_rtrn) { int ok = 0; - uint32_t sym; + xkb_keysym_t sym; if (expr->op == ExprIdent) { diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c index 1b63411..7148aad 100644 --- a/src/xkbcomp/parseutils.c +++ b/src/xkbcomp/parseutils.c @@ -608,9 +608,9 @@ AppendKeysymList(ExprDef * list, char *sym) } int -LookupKeysym(char *str, uint32_t * sym_rtrn) +LookupKeysym(char *str, xkb_keysym_t * sym_rtrn) { - uint32_t sym; + xkb_keysym_t sym; if ((!str) || (uStrCaseCmp(str, "any") == 0) || (uStrCaseCmp(str, "nosymbol") == 0)) diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/parseutils.h index 0733455..efb3317 100644 --- a/src/xkbcomp/parseutils.h +++ b/src/xkbcomp/parseutils.h @@ -147,7 +147,7 @@ extern ExprDef *AppendKeysymList(ExprDef * /* list */ , ); extern int LookupKeysym(char * /* str */ , - uint32_t * /* sym_rtrn */ + xkb_keysym_t * /* sym_rtrn */ ); extern IncludeStmt *IncludeCreate(char * /* str */ , diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index 1d6c6d8..97ccae5 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -64,7 +64,7 @@ typedef struct _KeyInfo unsigned char symsDefined; unsigned char actsDefined; short numLevels[XkbNumKbdGroups]; - uint32_t *syms[XkbNumKbdGroups]; + xkb_keysym_t *syms[XkbNumKbdGroups]; union xkb_action *acts[XkbNumKbdGroups]; uint32_t types[XkbNumKbdGroups]; unsigned repeat; @@ -168,14 +168,14 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld) width = new->numLevels[i]; if (old->syms[i] != NULL) { - new->syms[i] = uTypedCalloc(width, uint32_t); + new->syms[i] = uTypedCalloc(width, xkb_keysym_t); if (!new->syms[i]) { new->syms[i] = NULL; new->numLevels[i] = 0; return False; } - memcpy(new->syms[i], old->syms[i], width * sizeof(uint32_t)); + memcpy(new->syms[i], old->syms[i], width * sizeof(xkb_keysym_t)); } if (old->acts[i] != NULL) { @@ -203,7 +203,7 @@ typedef struct _ModMapEntry union { unsigned long keyName; - uint32_t keySym; + xkb_keysym_t keySym; } u; } ModMapEntry; @@ -288,7 +288,7 @@ ResizeKeyGroup(KeyInfo * key, { key->syms[group] = uTypedRecalloc(key->syms[group], key->numLevels[group], newWidth, - uint32_t); + xkb_keysym_t); if (!key->syms[group]) return False; } @@ -309,7 +309,7 @@ static Bool MergeKeyGroups(SymbolsInfo * info, KeyInfo * into, KeyInfo * from, unsigned group) { - uint32_t *resultSyms; + xkb_keysym_t *resultSyms; union xkb_action *resultActs; int resultWidth; int i; @@ -332,7 +332,7 @@ MergeKeyGroups(SymbolsInfo * info, } if (resultSyms == NULL) { - resultSyms = uTypedCalloc(resultWidth, uint32_t); + resultSyms = uTypedCalloc(resultWidth, xkb_keysym_t); if (!resultSyms) { WSGO("Could not allocate symbols for group merge\n"); @@ -357,7 +357,7 @@ MergeKeyGroups(SymbolsInfo * info, } for (i = 0; i < resultWidth; i++) { - uint32_t fromSym, toSym; + xkb_keysym_t fromSym, toSym; if (from->syms[group] && (i < from->numLevels[group])) fromSym = from->syms[group][i]; else @@ -372,7 +372,7 @@ MergeKeyGroups(SymbolsInfo * info, resultSyms[i] = fromSym; else { - uint32_t use, ignore; + xkb_keysym_t use, ignore; if (clobber) { use = fromSym; @@ -1638,7 +1638,7 @@ HandleSymbolsFile(XkbFile * file, } static Bool -FindKeyForSymbol(struct xkb_desc * xkb, uint32_t sym, xkb_keycode_t *kc_rtrn) +FindKeyForSymbol(struct xkb_desc * xkb, xkb_keysym_t sym, xkb_keycode_t *kc_rtrn) { int i, j; Bool gotOne; @@ -1710,7 +1710,7 @@ FindNamedType(struct xkb_desc * xkb, uint32_t atom, unsigned *type_rtrn) * @returns True if a type could be found, False otherwise. */ static Bool -FindAutomaticType(int width, uint32_t * syms, uint32_t * typeNameRtrn, +FindAutomaticType(int width, xkb_keysym_t * syms, xkb_atom_t * typeNameRtrn, Bool * autoType) { *autoType = False; @@ -1803,10 +1803,10 @@ PrepareKeyDef(KeyInfo * key) } if ((key->symsDefined & 1) && key->syms[0]) { - key->syms[i] = uTypedCalloc(width, uint32_t); + key->syms[i] = uTypedCalloc(width, xkb_keysym_t); if (key->syms[i] == NULL) continue; - memcpy(key->syms[i], key->syms[0], width * sizeof(uint32_t)); + memcpy(key->syms[i], key->syms[0], width * sizeof(xkb_keysym_t)); key->symsDefined |= 1 << i; } if (defined & 1) @@ -1828,7 +1828,7 @@ PrepareKeyDef(KeyInfo * key) if ((key->syms[i] != key->syms[0]) && (key->syms[i] == NULL || key->syms[0] == NULL || memcmp(key->syms[i], key->syms[0], - sizeof(uint32_t) * key->numLevels[0]))) + sizeof(xkb_keysym_t) * key->numLevels[0]))) { identical = False; break; @@ -1872,7 +1872,7 @@ CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from) unsigned width, tmp, nGroups; struct xkb_key_type * type; Bool haveActions, autoType, useAlias; - uint32_t *outSyms; + xkb_keysym_t *outSyms; union xkb_action *outActs; unsigned types[XkbNumKbdGroups]; diff --git a/src/xkbmisc.h b/src/xkbmisc.h index 3271f31..198c9d1 100644 --- a/src/xkbmisc.h +++ b/src/xkbmisc.h @@ -50,7 +50,7 @@ extern void XkbcEnsureSafeMapName(char *name); extern unsigned -_XkbcKSCheckCase(uint32_t sym); +_XkbcKSCheckCase(xkb_keysym_t sym); #define _XkbKSLower (1 << 0) #define _XkbKSUpper (1 << 1) @@ -97,7 +97,7 @@ extern const char * XkbcActionTypeText(unsigned type); extern const char * -XkbcKeysymText(uint32_t sym); +XkbcKeysymText(xkb_keysym_t sym); extern const char * XkbcKeyNameText(char *name);