keysym: add xkb_keysym_to_{lower,upper}

These functions are needed later; they are not API functions. The
capitalization is not locale sensitive.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2013-08-13 18:52:46 +03:00
parent 884e0079e0
commit 1499eedd82
3 changed files with 39 additions and 0 deletions

View File

@ -242,6 +242,26 @@ xkb_keysym_is_upper(xkb_keysym_t ks)
return (ks == upper ? true : false); return (ks == upper ? true : false);
} }
xkb_keysym_t
xkb_keysym_to_lower(xkb_keysym_t ks)
{
xkb_keysym_t lower, upper;
XConvertCase(ks, &lower, &upper);
return lower;
}
xkb_keysym_t
xkb_keysym_to_upper(xkb_keysym_t ks)
{
xkb_keysym_t lower, upper;
XConvertCase(ks, &lower, &upper);
return upper;
}
/* /*
* The following is copied verbatim from libX11:src/KeyBind.c, commit * The following is copied verbatim from libX11:src/KeyBind.c, commit
* d45b3fc19fbe95c41afc4e51d768df6d42332010, with the following changes: * d45b3fc19fbe95c41afc4e51d768df6d42332010, with the following changes:

View File

@ -59,4 +59,10 @@ xkb_keysym_is_upper(xkb_keysym_t keysym);
bool bool
xkb_keysym_is_keypad(xkb_keysym_t keysym); xkb_keysym_is_keypad(xkb_keysym_t keysym);
xkb_keysym_t
xkb_keysym_to_upper(xkb_keysym_t ks);
xkb_keysym_t
xkb_keysym_to_lower(xkb_keysym_t ks);
#endif #endif

View File

@ -183,5 +183,18 @@ main(void)
assert(!xkb_keysym_is_keypad(XKB_KEY_1)); assert(!xkb_keysym_is_keypad(XKB_KEY_1));
assert(!xkb_keysym_is_keypad(XKB_KEY_Return)); assert(!xkb_keysym_is_keypad(XKB_KEY_Return));
assert(xkb_keysym_to_upper(XKB_KEY_a) == XKB_KEY_A);
assert(xkb_keysym_to_upper(XKB_KEY_A) == XKB_KEY_A);
assert(xkb_keysym_to_lower(XKB_KEY_a) == XKB_KEY_a);
assert(xkb_keysym_to_lower(XKB_KEY_A) == XKB_KEY_a);
assert(xkb_keysym_to_upper(XKB_KEY_Return) == XKB_KEY_Return);
assert(xkb_keysym_to_lower(XKB_KEY_Return) == XKB_KEY_Return);
assert(xkb_keysym_to_upper(XKB_KEY_Greek_lambda) == XKB_KEY_Greek_LAMBDA);
assert(xkb_keysym_to_upper(XKB_KEY_Greek_LAMBDA) == XKB_KEY_Greek_LAMBDA);
assert(xkb_keysym_to_lower(XKB_KEY_Greek_lambda) == XKB_KEY_Greek_lambda);
assert(xkb_keysym_to_lower(XKB_KEY_Greek_LAMBDA) == XKB_KEY_Greek_lambda);
assert(xkb_keysym_to_upper(XKB_KEY_eacute) == XKB_KEY_Eacute);
assert(xkb_keysym_to_lower(XKB_KEY_Eacute) == XKB_KEY_eacute);
return 0; return 0;
} }