Introduce xkb_keysym_t type Signed-off-by: Daniel Stone <daniel@fooishbar.org>
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 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
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 <X11/extensions/XKB.h>
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);