Define our own NoSymbol value and use it Since we have our own xkb_keysym_t type, it makes sense to have our own NoSymbol value instead of the one from X11/X.h. 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 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
diff --git a/include/xkbcommon/xkbcommon.h b/include/xkbcommon/xkbcommon.h
index 0679235..b823890 100644
--- a/include/xkbcommon/xkbcommon.h
+++ b/include/xkbcommon/xkbcommon.h
@@ -97,6 +97,8 @@ typedef uint32_t xkb_led_index_t;
#define XKB_KEYCODE_INVALID (0xffffffff)
#define XKB_LED_INVALID (0xffffffff)
+#define XKB_KEYSYM_NO_SYMBOL 0
+
#define XKB_KEYCODE_MAX (0xffffffff - 1)
#define xkb_keycode_is_legal_ext(kc) (kc <= XKB_KEYCODE_MAX)
#define xkb_keycode_is_legal_x11(kc) (kc <= XKB_KEYCODE_MAX)
diff --git a/makekeys/makekeys.c b/makekeys/makekeys.c
index c731e40..4d7767f 100644
--- a/makekeys/makekeys.c
+++ b/makekeys/makekeys.c
@@ -26,7 +26,10 @@ from The Open Group.
*/
-/* Constructs hash tables for XStringToKeysym and XKeysymToString. */
+/*
+ * Constructs hash tables for xkb_keysym_to_string and
+ * xkb_string_from_keysym.
+ */
#include "xkbcommon/xkbcommon.h"
@@ -151,9 +154,9 @@ main(int argc, char *argv[])
fclose(fptr);
}
- /* Special case NoSymbol. */
+ /* Special case XKB_KEYSYM_NO_SYMBOL. */
info[ksnum].name = strdup("NoSymbol");
- info[ksnum].val = 0L;
+ info[ksnum].val = XKB_KEYSYM_NO_SYMBOL;
ksnum++;
printf("/* This file is generated from keysymdef.h. */\n");
diff --git a/src/keysym.c b/src/keysym.c
index 24fdf52..a5cbc44 100644
--- a/src/keysym.c
+++ b/src/keysym.c
@@ -28,7 +28,6 @@ authorization from the authors.
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <X11/X.h>
#include <X11/keysymdef.h>
#include "xkbmisc.h"
#include "xkbcommon/xkbcommon.h"
@@ -50,7 +49,7 @@ xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size)
}
/* Not listed in keysymdef.h for hysterical raisins. */
- if (ks == NoSymbol) {
+ if (ks == XKB_KEYSYM_NO_SYMBOL) {
snprintf(buffer, size, "NoSymbol");
return;
}
@@ -135,11 +134,11 @@ xkb_string_to_keysym(const char *s)
val = strtoul(&s[1], NULL, 16);
if (val < 0x20 || (val > 0x7e && val < 0xa0))
- return NoSymbol;
+ return XKB_KEYSYM_NO_SYMBOL;
if (val < 0x100)
return val;
if (val > 0x10ffff)
- return NoSymbol;
+ return XKB_KEYSYM_NO_SYMBOL;
return val | 0x01000000;
}
else if (s[0] == '0' && s[1] == 'x') {
@@ -153,12 +152,12 @@ xkb_string_to_keysym(const char *s)
xkb_keysym_t ret;
char *tmp = strdup(s);
if (!tmp)
- return NoSymbol;
+ return XKB_KEYSYM_NO_SYMBOL;
memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1);
ret = xkb_string_to_keysym(tmp);
free(tmp);
return ret;
}
- return NoSymbol;
+ return XKB_KEYSYM_NO_SYMBOL;
}
diff --git a/src/malloc.c b/src/malloc.c
index 6168a67..37e513c 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -92,7 +92,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
return BadAlloc;
}
map->num_syms = 1;
- map->syms[0] = NoSymbol;
+ map->syms[0] = XKB_KEYSYM_NO_SYMBOL;
}
if (!map->key_sym_map) {
@@ -295,7 +295,7 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
if (!newSyms)
return NULL;
- newSyms[0] = NoSymbol;
+ newSyms[0] = XKB_KEYSYM_NO_SYMBOL;
nSyms = 1;
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
uint32_t nCopy;
diff --git a/src/map.c b/src/map.c
index e51a67a..114b0de 100644
--- a/src/map.c
+++ b/src/map.c
@@ -305,7 +305,7 @@ xkb_key_get_syms_by_level(struct xkb_desc *xkb, xkb_keycode_t key, unsigned int
unsigned int level, xkb_keysym_t **syms_out)
{
*syms_out = &(XkbKeySymEntry(xkb, key, level, group));
- if (**syms_out == NoSymbol)
+ if (**syms_out == XKB_KEYSYM_NO_SYMBOL)
goto err;
return 1;
diff --git a/src/xkballoc.h b/src/xkballoc.h
index 2e0a23e..d16c58b 100644
--- a/src/xkballoc.h
+++ b/src/xkballoc.h
@@ -27,7 +27,6 @@ authorization from the authors.
#ifndef _XKBALLOC_H_
#define _XKBALLOC_H_
-#include <X11/Xdefs.h>
#include <X11/X.h>
#include "xkbcommon/xkbcommon.h"
#include "XKBcommonint.h"
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index eca1d6d..d0e2f0f 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -24,8 +24,6 @@
********************************************************/
-#include <X11/X.h>
-
#include "xkbcomp.h"
#include "xkbmisc.h"
#include "expr.h"
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 31de1e4..38cd013 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -24,7 +24,6 @@
********************************************************/
-#include <X11/Xos.h>
#include "xkbcomp.h"
#include "xkballoc.h"
#include "xkbmisc.h"
@@ -778,8 +777,8 @@ CopyInterps(CompatInfo * info,
for (si = info->interps; si; si = (SymInterpInfo *) si->defs.next)
{
if (((si->interp.match & XkbSI_OpMask) != pred) ||
- (needSymbol && (si->interp.sym == NoSymbol)) ||
- ((!needSymbol) && (si->interp.sym != NoSymbol)))
+ (needSymbol && (si->interp.sym == XKB_KEYSYM_NO_SYMBOL)) ||
+ ((!needSymbol) && (si->interp.sym != XKB_KEYSYM_NO_SYMBOL)))
continue;
if (compat->num_si >= compat->size_si)
{
@@ -894,7 +893,7 @@ UpdateActionMods(struct xkb_desc *xkb, union xkb_action *act, uint32_t rmodmask)
/**
* Find an interpretation which applies to this particular level, either by
* finding an exact match for the symbol and modifier combination, or a
- * generic NoSymbol match.
+ * generic XKB_KEYSYM_NO_SYMBOL match.
*/
static struct xkb_sym_interpret *
FindInterpForKey(struct xkb_desc *xkb, xkb_keycode_t key, uint32_t group, uint32_t level)
@@ -914,7 +913,7 @@ FindInterpForKey(struct xkb_desc *xkb, xkb_keycode_t key, uint32_t group, uint32
Bool found;
if ((num_syms != 1 || interp->sym != syms[0]) &&
- interp->sym != NoSymbol)
+ interp->sym != XKB_KEYSYM_NO_SYMBOL)
continue;
if (level == 0 || !(interp->match & XkbSI_LevelOneOnly))
@@ -943,7 +942,7 @@ FindInterpForKey(struct xkb_desc *xkb, xkb_keycode_t key, uint32_t group, uint32
break;
}
- if (found && interp->sym != NoSymbol)
+ if (found && interp->sym != XKB_KEYSYM_NO_SYMBOL)
return interp;
else if (found && !ret)
ret = interp;
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 75c59ad..694d0c6 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -30,7 +30,6 @@
#include "vmod.h"
#include <ctype.h>
-#include <X11/X.h>
/***====================================================================***/
@@ -985,10 +984,12 @@ ExprResolveKeySym(ExprDef * expr,
{
const char *str;
str = XkbcAtomText(expr->value.str);
- if ((str != NULL) && ((sym = xkb_string_to_keysym(str)) != NoSymbol))
- {
- val_rtrn->uval = sym;
- return True;
+ if (str) {
+ sym = xkb_string_to_keysym(str);
+ if (sym != XKB_KEYSYM_NO_SYMBOL) {
+ val_rtrn->uval = sym;
+ return True;
+ }
}
}
ok = ExprResolveInteger(expr, val_rtrn);
diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c
index 631a452..1d66986 100644
--- a/src/xkbcomp/parseutils.c
+++ b/src/xkbcomp/parseutils.c
@@ -440,7 +440,7 @@ LookupKeysym(char *str, xkb_keysym_t * sym_rtrn)
if ((!str) || (strcasecmp(str, "any") == 0) ||
(strcasecmp(str, "nosymbol") == 0))
{
- *sym_rtrn = NoSymbol;
+ *sym_rtrn = XKB_KEYSYM_NO_SYMBOL;
return 1;
}
else if ((strcasecmp(str, "none") == 0) ||
@@ -450,7 +450,7 @@ LookupKeysym(char *str, xkb_keysym_t * sym_rtrn)
return 1;
}
sym = xkb_string_to_keysym(str);
- if (sym != NoSymbol)
+ if (sym != XKB_KEYSYM_NO_SYMBOL)
{
*sym_rtrn = sym;
return 1;
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index ddb7afb..b3953c1 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -358,14 +358,14 @@ MergeKeyGroups(SymbolsInfo * info,
if (from->syms[group] && (i < from->numLevels[group]))
fromSym = from->syms[group][i];
else
- fromSym = NoSymbol;
+ fromSym = XKB_KEYSYM_NO_SYMBOL;
if (into->syms[group] && (i < into->numLevels[group]))
toSym = into->syms[group][i];
else
- toSym = NoSymbol;
- if ((fromSym == NoSymbol) || (fromSym == toSym))
+ toSym = XKB_KEYSYM_NO_SYMBOL;
+ if ((fromSym == XKB_KEYSYM_NO_SYMBOL) || (fromSym == toSym))
resultSyms[i] = toSym;
- else if (toSym == NoSymbol)
+ else if (toSym == XKB_KEYSYM_NO_SYMBOL)
resultSyms[i] = fromSym;
else
{
@@ -927,11 +927,11 @@ AddSymbolsToKey(KeyInfo * key,
WARN("Could not resolve keysym %s for key %s, group %d (%s), level %d\n",
value->value.list.syms[i], longText(key->name), ndx + 1,
XkbcAtomText(info->groupNames[ndx]), nSyms);
- key->syms[ndx][i] = NoSymbol;
+ key->syms[ndx][i] = XKB_KEYSYM_NO_SYMBOL;
}
}
for (j = key->numLevels[ndx] - 1;
- (j >= 0) && (key->syms[ndx][j] == NoSymbol); j--)
+ (j >= 0) && (key->syms[ndx][j] == XKB_KEYSYM_NO_SYMBOL); j--)
{
key->numLevels[ndx]--;
}
@@ -1878,7 +1878,7 @@ CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
if (tmp < key->numLevels[i])
outSyms[tmp] = key->syms[i][tmp];
else
- outSyms[tmp] = NoSymbol;
+ outSyms[tmp] = XKB_KEYSYM_NO_SYMBOL;
if ((outActs != NULL) && (key->acts[i] != NULL))
{
if (tmp < key->numLevels[i])
diff --git a/src/xkbcomp/xkbpath.h b/src/xkbcomp/xkbpath.h
index 0273e9b..3632cbb 100644
--- a/src/xkbcomp/xkbpath.h
+++ b/src/xkbcomp/xkbpath.h
@@ -28,7 +28,6 @@
#define _XKBPATH_H_ 1
#include <stdio.h>
-#include <X11/X.h>
#include <X11/Xdefs.h>
extern const char *XkbDirectoryForInclude(unsigned /* type */
diff --git a/src/xkbcomp/xkbscan.l b/src/xkbcomp/xkbscan.l
index 8120681..599a388 100644
--- a/src/xkbcomp/xkbscan.l
+++ b/src/xkbcomp/xkbscan.l
@@ -28,7 +28,6 @@
#include <stdio.h>
#include <ctype.h>
-#include <X11/Xos.h>
#include "utils.h"
#include "parseutils.h"
diff --git a/test/xkey.c b/test/xkey.c
index 52914a2..51909c2 100644
--- a/test/xkey.c
+++ b/test/xkey.c
@@ -3,12 +3,11 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <X11/X.h>
static void print_keysym(const char *s)
{
xkb_keysym_t ks = xkb_string_to_keysym(s);
- if (ks == NoSymbol)
+ if (ks == XKB_KEYSYM_NO_SYMBOL)
printf("NoSymbol\n");
else
printf("0x%lX\n", ks);