Rename keysym <-> string API Change them to refer to the string representation of the keysym's name as a name rather than a string, since we want to add API to get the Unicode printable representation as well. 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
diff --git a/include/xkbcommon/xkbcommon.h b/include/xkbcommon/xkbcommon.h
index dac14ec..315f590 100644
--- a/include/xkbcommon/xkbcommon.h
+++ b/include/xkbcommon/xkbcommon.h
@@ -172,18 +172,18 @@ xkb_canonicalise_components(struct xkb_component_names *names,
const struct xkb_component_names *old);
/*
- * Converts a keysym to a string; will return unknown Unicode codepoints
- * as "Ua1b2", and other unknown keysyms as "0xabcd1234".
+ * Returns the name for a keysym as a string; will return unknown Unicode
+ * codepoints as "Ua1b2", and other unknown keysyms as "0xabcd1234".
*/
void
-xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size);
+xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size);
/*
* See xkb_keysym_to_string comments: this function will accept any string
* from that function.
*/
xkb_keysym_t
-xkb_string_to_keysym(const char *s);
+xkb_keysym_from_name(const char *s);
/**
* @defgroup ctx XKB contexts
diff --git a/src/keysym.c b/src/keysym.c
index 06a3b37..ad590da 100644
--- a/src/keysym.c
+++ b/src/keysym.c
@@ -34,7 +34,7 @@ authorization from the authors.
#include "ks_tables.h"
_X_EXPORT void
-xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size)
+xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size)
{
int i, n, h, idx;
const unsigned char *entry;
@@ -88,7 +88,7 @@ xkb_keysym_to_string(xkb_keysym_t ks, char *buffer, size_t size)
}
_X_EXPORT xkb_keysym_t
-xkb_string_to_keysym(const char *s)
+xkb_keysym_from_name(const char *s)
{
int i, n, h, c, idx;
uint32_t sig = 0;
@@ -158,7 +158,7 @@ xkb_string_to_keysym(const char *s)
if (!tmp)
return XKB_KEYSYM_NO_SYMBOL;
memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1);
- ret = xkb_string_to_keysym(tmp);
+ ret = xkb_keysym_from_name(tmp);
free(tmp);
return ret;
}
diff --git a/src/text.c b/src/text.c
index 9277268..d9aede4 100644
--- a/src/text.c
+++ b/src/text.c
@@ -245,7 +245,7 @@ XkbcKeysymText(xkb_keysym_t sym)
{
static char buffer[16];
- xkb_keysym_to_string(sym, buffer, sizeof buffer);
+ xkb_keysym_get_name(sym, buffer, sizeof buffer);
return buffer;
}
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 8e1e81f..2b82ce3 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -977,7 +977,7 @@ ExprResolveKeySym(ExprDef * expr,
const char *str;
str = XkbcAtomText(expr->value.str);
if (str) {
- sym = xkb_string_to_keysym(str);
+ sym = xkb_keysym_from_name(str);
if (sym != XKB_KEYSYM_NO_SYMBOL) {
val_rtrn->uval = sym;
return true;
diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c
index 31e478d..8bfafa4 100644
--- a/src/xkbcomp/parseutils.c
+++ b/src/xkbcomp/parseutils.c
@@ -546,7 +546,7 @@ LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
*sym_rtrn = XK_VoidSymbol;
return 1;
}
- sym = xkb_string_to_keysym(str);
+ sym = xkb_keysym_from_name(str);
if (sym != XKB_KEYSYM_NO_SYMBOL)
{
*sym_rtrn = sym;
diff --git a/test/xkey.c b/test/xkey.c
index 3024a4d..6768506 100644
--- a/test/xkey.c
+++ b/test/xkey.c
@@ -10,7 +10,7 @@ test_string(const char *string, xkb_keysym_t expected)
{
xkb_keysym_t keysym;
- keysym = xkb_string_to_keysym(string);
+ keysym = xkb_keysym_from_name(string);
fprintf(stderr, "Expected string %s -> %x\n", string, expected);
fprintf(stderr, "Received string %s -> %x\n\n", string, keysym);
@@ -23,7 +23,7 @@ test_keysym(xkb_keysym_t keysym, const char *expected)
{
char s[16];
- xkb_keysym_to_string(keysym, s, sizeof(s));
+ xkb_keysym_get_name(keysym, s, sizeof(s));
fprintf(stderr, "Expected keysym %#x -> %s\n", keysym, expected);
fprintf(stderr, "Received keysym %#x -> %s\n\n", keysym, s);