xkb.compose: get locale from user env settings
The setlocale call will only give useful results if the program had previously set the current locale using setlocale... See also "Compose Locale" section in xkbcommon doc: https://xkbcommon.org/doc/current/group__compose.html#compose-locale Fixes: QTBUG-85529 Change-Id: I65b1ac86ea54445bc3a2e1707df79bd9f732ab46 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 73ea9f032864566cc019d286b2f210b78cd70a3d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
b29941f6db
commit
2e00264fe9
@ -71,10 +71,16 @@ void QComposeInputContext::ensureInitialized()
|
||||
}
|
||||
|
||||
m_initialized = true;
|
||||
const char *locale = setlocale(LC_CTYPE, "");
|
||||
if (!locale)
|
||||
locale = setlocale(LC_CTYPE, nullptr);
|
||||
qCDebug(lcXkbCompose) << "detected locale (LC_CTYPE):" << locale;
|
||||
// Get locale from user env settings, see also
|
||||
// https://xkbcommon.org/doc/current/group__compose.html#compose-locale
|
||||
const char *locale = getenv("LC_ALL");
|
||||
if (!locale || !*locale)
|
||||
locale = getenv("LC_CTYPE");
|
||||
if (!locale || !*locale)
|
||||
locale = getenv("LANG");
|
||||
if (!locale || !*locale)
|
||||
locale = "C";
|
||||
qCDebug(lcXkbCompose) << "detected locale:" << locale;
|
||||
|
||||
m_composeTable = xkb_compose_table_new_from_locale(m_XkbContext, locale, XKB_COMPOSE_COMPILE_NO_FLAGS);
|
||||
if (m_composeTable)
|
||||
|
Loading…
x
Reference in New Issue
Block a user