keysym: add xkb_keysym_to_{lower,upper} to public API

These can be useful in some odd cases.

There is already an implementation (+ tests) for internal use, so all
that's needed is to export them.

If xkbcommon were to provide a way to convert a Unicode codepoint to a
keysym, this could have been implemented externally as follows:

    uint32_t codepoint = xkb_keysym_to_utf32(keysym);
    uint32_t upper_codepoint = my_unicode_library_to_upper(codepoint);
    xkb_keysym_t upper_keysym = theoretical_xkb_keysym_from_utf32(upper_codepoint);

However keysym -> codepoint is not injective so such a function is not
possible strictly speaking.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2017-12-11 22:41:55 +02:00
parent 6456835f1c
commit 18d6aebec0
5 changed files with 41 additions and 8 deletions

13
NEWS
View File

@ -1,3 +1,16 @@
libxkbcommon 0.8.0 - UNRELEASED
- Add xkb_keysym_to_{upper,lower} to perform case-conversion directly on
keysyms. This is useful in some odd cases, but working with the Unicode
representations should be preferred when possible.
- Added Unicode conversion rules for the signifblank and permille keysyms.
- New API:
xkb_keysym_to_upper()
xkb_keysym_to_lower()
==================
libxkbcommon 0.7.2 - 2017-08-04 libxkbcommon 0.7.2 - 2017-08-04
================== ==================

View File

@ -264,7 +264,7 @@ xkb_keysym_is_upper(xkb_keysym_t ks)
return (ks == upper ? true : false); return (ks == upper ? true : false);
} }
xkb_keysym_t XKB_EXPORT xkb_keysym_t
xkb_keysym_to_lower(xkb_keysym_t ks) xkb_keysym_to_lower(xkb_keysym_t ks)
{ {
xkb_keysym_t lower, upper; xkb_keysym_t lower, upper;
@ -274,7 +274,7 @@ xkb_keysym_to_lower(xkb_keysym_t ks)
return lower; return lower;
} }
xkb_keysym_t XKB_EXPORT xkb_keysym_t
xkb_keysym_to_upper(xkb_keysym_t ks) xkb_keysym_to_upper(xkb_keysym_t ks)
{ {
xkb_keysym_t lower, upper; xkb_keysym_t lower, upper;

View File

@ -62,10 +62,4 @@ xkb_keysym_is_keypad(xkb_keysym_t keysym);
bool bool
xkb_keysym_is_modifier(xkb_keysym_t keysym); xkb_keysym_is_modifier(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

@ -97,3 +97,9 @@ global:
xkb_state_key_get_consumed_mods2; xkb_state_key_get_consumed_mods2;
xkb_state_mod_index_is_consumed2; xkb_state_mod_index_is_consumed2;
} V_0.6.0; } V_0.6.0;
V_0.8.0 {
global:
xkb_keysym_to_lower;
xkb_keysym_to_upper;
} V_0.7.0;

View File

@ -493,6 +493,26 @@ xkb_keysym_to_utf8(xkb_keysym_t keysym, char *buffer, size_t size);
uint32_t uint32_t
xkb_keysym_to_utf32(xkb_keysym_t keysym); xkb_keysym_to_utf32(xkb_keysym_t keysym);
/**
* Convert a keysym to its uppercase form.
*
* If there is no such form, the keysym is returned unchanged.
*
* The conversion rules may be incomplete; prefer to work with the Unicode
* representation instead, when possible.
*/
xkb_keysym_t
xkb_keysym_to_upper(xkb_keysym_t ks);
/**
* Convert a keysym to its lowercase form.
*
* The conversion rules may be incomplete; prefer to work with the Unicode
* representation instead, when possible.
*/
xkb_keysym_t
xkb_keysym_to_lower(xkb_keysym_t ks);
/** @} */ /** @} */
/** /**