From: Ran Benita Date: Tue, 13 Aug 2013 15:52:46 +0000 (+0300) Subject: keysym: add xkb_keysym_to_{lower,upper} X-Git-Tag: xkbcommon-0.3.2~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1499eedd82998f28b437cf455d84f63f1a108cee;p=platform%2Fupstream%2Flibxkbcommon.git 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 --- diff --git a/src/keysym.c b/src/keysym.c index 1e92a4a..33b6491 100644 --- a/src/keysym.c +++ b/src/keysym.c @@ -242,6 +242,26 @@ xkb_keysym_is_upper(xkb_keysym_t ks) 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 * d45b3fc19fbe95c41afc4e51d768df6d42332010, with the following changes: diff --git a/src/keysym.h b/src/keysym.h index 6f2280b..e9374dc 100644 --- a/src/keysym.h +++ b/src/keysym.h @@ -59,4 +59,10 @@ xkb_keysym_is_upper(xkb_keysym_t keysym); bool 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 diff --git a/test/keysym.c b/test/keysym.c index 46d70ac..439622c 100644 --- a/test/keysym.c +++ b/test/keysym.c @@ -183,5 +183,18 @@ main(void) assert(!xkb_keysym_is_keypad(XKB_KEY_1)); 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; }