qxkbcommon: Keep lower case as Qt key when upper case is not in Latin1

Upper-casing a Latin1 character might move it out of Latin1 range,
for example U+00B5 MICRO SIGN, which upper-case equivalent is
U+039C GREEK CAPITAL LETTER MU. If that's the case, then map the
original lower-case character.

Fixes: QTBUG-93858
Pick-to: 5.15 6.0 6.1
Change-Id: Ibd86fbb7c70d620c0884015ec1c40aa6351e6320
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Andrey Butirsky <butirsky@gmail.com>
This commit is contained in:
Andrey Butirsky 2021-05-20 03:35:26 +03:00 committed by Tor Arne Vestbø
parent 6519bcf85d
commit 6ecde6265a

View File

@ -545,7 +545,15 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
// numeric keypad keys
qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
} else if (QXkbCommon::isLatin1(keysym)) {
// Upper-case first, since Qt::Keys are defined in terms of their
// upper-case versions.
qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
// Upper-casing a Latin1 character might move it out of Latin1 range,
// for example U+00B5 MICRO SIGN, which upper-case equivalent is
// U+039C GREEK CAPITAL LETTER MU. If that's the case, then map the
// original lower-case character.
if (!QXkbCommon::isLatin1(qtKey))
qtKey = keysym;
} else {
// check if we have a direct mapping
xkb2qt_t searchKey{keysym, 0};