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>
master
Daniel Stone 2012-05-09 13:22:34 +01:00
parent 124e62e48f
commit e1af48bc04
6 changed files with 12 additions and 12 deletions

View File

@ -172,18 +172,18 @@ xkb_canonicalise_components(struct xkb_component_names *names,
const struct xkb_component_names *old); const struct xkb_component_names *old);
/* /*
* Converts a keysym to a string; will return unknown Unicode codepoints * Returns the name for a keysym as a string; will return unknown Unicode
* as "Ua1b2", and other unknown keysyms as "0xabcd1234". * codepoints as "Ua1b2", and other unknown keysyms as "0xabcd1234".
*/ */
void 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 * See xkb_keysym_to_string comments: this function will accept any string
* from that function. * from that function.
*/ */
xkb_keysym_t xkb_keysym_t
xkb_string_to_keysym(const char *s); xkb_keysym_from_name(const char *s);
/** /**
* @defgroup ctx XKB contexts * @defgroup ctx XKB contexts

View File

@ -34,7 +34,7 @@ authorization from the authors.
#include "ks_tables.h" #include "ks_tables.h"
_X_EXPORT void _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; int i, n, h, idx;
const unsigned char *entry; 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 _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; int i, n, h, c, idx;
uint32_t sig = 0; uint32_t sig = 0;
@ -158,7 +158,7 @@ xkb_string_to_keysym(const char *s)
if (!tmp) if (!tmp)
return XKB_KEYSYM_NO_SYMBOL; return XKB_KEYSYM_NO_SYMBOL;
memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1); memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1);
ret = xkb_string_to_keysym(tmp); ret = xkb_keysym_from_name(tmp);
free(tmp); free(tmp);
return ret; return ret;
} }

View File

@ -245,7 +245,7 @@ XkbcKeysymText(xkb_keysym_t sym)
{ {
static char buffer[16]; static char buffer[16];
xkb_keysym_to_string(sym, buffer, sizeof buffer); xkb_keysym_get_name(sym, buffer, sizeof buffer);
return buffer; return buffer;
} }

View File

@ -977,7 +977,7 @@ ExprResolveKeySym(ExprDef * expr,
const char *str; const char *str;
str = XkbcAtomText(expr->value.str); str = XkbcAtomText(expr->value.str);
if (str) { if (str) {
sym = xkb_string_to_keysym(str); sym = xkb_keysym_from_name(str);
if (sym != XKB_KEYSYM_NO_SYMBOL) { if (sym != XKB_KEYSYM_NO_SYMBOL) {
val_rtrn->uval = sym; val_rtrn->uval = sym;
return true; return true;

View File

@ -546,7 +546,7 @@ LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
*sym_rtrn = XK_VoidSymbol; *sym_rtrn = XK_VoidSymbol;
return 1; return 1;
} }
sym = xkb_string_to_keysym(str); sym = xkb_keysym_from_name(str);
if (sym != XKB_KEYSYM_NO_SYMBOL) if (sym != XKB_KEYSYM_NO_SYMBOL)
{ {
*sym_rtrn = sym; *sym_rtrn = sym;

View File

@ -10,7 +10,7 @@ test_string(const char *string, xkb_keysym_t expected)
{ {
xkb_keysym_t keysym; 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, "Expected string %s -> %x\n", string, expected);
fprintf(stderr, "Received string %s -> %x\n\n", string, keysym); 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]; 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, "Expected keysym %#x -> %s\n", keysym, expected);
fprintf(stderr, "Received keysym %#x -> %s\n\n", keysym, s); fprintf(stderr, "Received keysym %#x -> %s\n\n", keysym, s);