KeySym: Actually handle NoSymbol Add NoSymbol into the keysym table, so keysym <-> string conversion works for that, too; also eliminate special-casing of VoidSymbol. This will require special-casing in libX11 to preserve its API. 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
diff --git a/src/keysym.c b/src/keysym.c
index 4738fc2..3bcfd8f 100644
--- a/src/keysym.c
+++ b/src/keysym.c
@@ -42,13 +42,17 @@ XkbcKeysymToString(KeySym ks)
{
int i, n, h, idx;
const unsigned char *entry;
+ static char ret[11];
unsigned char val1, val2, val3, val4;
- if (!ks || (ks & ((unsigned long) ~0x1fffffff)) != 0)
+ if ((ks & ((unsigned long) ~0x1fffffff)) != 0)
return NULL;
- if (ks == XK_VoidSymbol)
- ks = 0;
+ /* Not listed in keysymdef.h for hysterical raisins. */
+ if (ks == NoSymbol) {
+ sprintf(ret, "NoSymbol");
+ return ret;
+ }
if (ks <= 0x1fffffff) {
val1 = ks >> 24;
diff --git a/src/makekeys/makekeys.c b/src/makekeys/makekeys.c
index 02b1efe..5e21964 100644
--- a/src/makekeys/makekeys.c
+++ b/src/makekeys/makekeys.c
@@ -206,8 +206,6 @@ main(int argc, char *argv[])
continue;
}
- if (info[ksnum].val == XK_VoidSymbol)
- info[ksnum].val = 0;
if (info[ksnum].val > 0x1fffffff) {
fprintf(stderr,
"ignoring illegal keysym (%s), remove it from .h file!\n",
@@ -228,6 +226,11 @@ main(int argc, char *argv[])
}
}
+ /* Special case NoSymbol. */
+ info[ksnum].name = strdup("NoSymbol");
+ info[ksnum].val = 0L;
+ ksnum++;
+
printf("/* This file is generated from keysymdef.h. */\n");
printf("/* Do not edit. */\n");
printf("\n");
diff --git a/test/xkey.sh b/test/xkey.sh
index 7e6b16b..e1bb73e 100755
--- a/test/xkey.sh
+++ b/test/xkey.sh
@@ -40,6 +40,7 @@ rm -f "$log"
check_string Undo 0xFF65
check_key 0x1008FF56 XF86Close
check_string ThisKeyShouldNotExist NoSymbol
-check_key 0x0 NULL
+check_key 0x0 NoSymbol
check_string XF86_Switch_VT_5 0x1008FE05
check_key 0x1008FE20 XF86_Ungrab
+check_string VoidSymbol 0xFFFFFF