summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2014-10-24 16:31:48 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2019-03-01 14:31:37 +0000
commit2065bc070dcd1f88a1f5ba3dd6ef0139a9a441ec (patch)
treeb31ce3dc68ff29274399708edb61a840daaf383b /src/platformsupport
parenta34e81ab8be6445877e040b1afb85deeaa725f86 (diff)
platforminputcontexts: use libxkbcommon compose key API
Our implementation of compose table parser was added on Mar, 2013. libxkbcommon added APIs for the same thing in Oct, 2014 (ver: 0.5.0). After removing RHEL 6.6 from the list of supported platforms we were able to move the minimal required libxkbcommon version to 0.5.0. Now we can use the xkbcommon-compose APIs on all supported platforms. With this patch we can drop nearly 1000 lines of maintenance burden. This patch fixes user reported issues with our implementation. Known issues: - Testing revealed that xkbcommon-compose does not support non-utf8 locales, and that is by design - https://github.com/xkbcommon/libxkbcommon/issues/76 Our implementation did work for those locales too, but it is unclear if anyone actually uses non-utf8 locales. It is a corner case (work-arounds existing) and likely a configuration error on the users' system. - Looking at the release notes for versions above 0.6.1, only one issue that stands out. Compose input does not work on system with tr_TR.UTF-8 locale, fixed in 0.7.1. Compose input works fine when using e.g. en_US.UTF-8 locale with Turkish keyboard layout. Note: With Qt 5.13 we have removed Ubuntu 16.04 and openSUSE 42.3 from CI: Ubuntu 16.04 - 0.5.0 openSUSE 42.3 - 0.6.1 CI for Qt 5.13 has: Ubuntu 18.04 - 0.8.0 RHEL-7.4 - 0.7.1 openSUSE 15.0 - 0.8.1 Currently the minimal required libxkbcommon version in src/gui/configure.json is set to 0.5.0, but we could bump it to 0.7.1 to avoid known issues from above, but that is a decision for a separate patch. [ChangeLog][plugins][platforminputcontexts] Now using libxkbcommon-compose APIs for compose key input, instead of Qt's own implementation. Fixes: QTBUG-42181 Fixes: QTBUG-53663 Fixes: QTBUG-48657 Change-Id: I79aafe2bc601293844066e7e5f5eddd3719c6bba Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com> Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/input/xkbcommon/qxkbcommon.cpp31
-rw-r--r--src/platformsupport/input/xkbcommon/qxkbcommon_p.h4
2 files changed, 35 insertions, 0 deletions
diff --git a/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
index 4bee868fa9..877c5d848f 100644
--- a/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+++ b/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
@@ -41,7 +41,12 @@
#include <private/qmakearray_p.h>
+#include <QtCore/QMetaMethod>
#include <QtGui/QKeyEvent>
+#include <QtGui/private/qguiapplication_p.h>
+
+#include <qpa/qplatforminputcontext.h>
+#include <qpa/qplatformintegration.h>
QT_BEGIN_NAMESPACE
@@ -794,4 +799,30 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
return sym;
}
+void QXkbCommon::setXkbContext(QPlatformInputContext *inputContext, struct xkb_context *context)
+{
+ if (!inputContext || !context)
+ return;
+
+ const char *const inputContextClassName = "QComposeInputContext";
+ const char *const normalizedSignature = "setXkbContext(xkb_context*)";
+
+ if (inputContext->objectName() != QLatin1String(inputContextClassName))
+ return;
+
+ static const QMetaMethod setXkbContext = [&]() {
+ int methodIndex = inputContext->metaObject()->indexOfMethod(normalizedSignature);
+ QMetaMethod method = inputContext->metaObject()->method(methodIndex);
+ Q_ASSERT(method.isValid());
+ if (!method.isValid())
+ qCWarning(lcXkbcommon) << normalizedSignature << "not found on" << inputContextClassName;
+ return method;
+ }();
+
+ if (!setXkbContext.isValid())
+ return;
+
+ setXkbContext.invoke(inputContext, Qt::DirectConnection, Q_ARG(struct xkb_context*, context));
+}
+
QT_END_NAMESPACE
diff --git a/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
index 475c51ad91..561eae03db 100644
--- a/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+++ b/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
@@ -64,7 +64,9 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcXkbcommon)
+class QEvent;
class QKeyEvent;
+class QPlatformInputContext;
class QXkbCommon
{
@@ -99,6 +101,8 @@ public:
return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
}
+ static void setXkbContext(QPlatformInputContext *inputContext, struct xkb_context *context);
+
struct XKBStateDeleter {
void operator()(struct xkb_state *state) const { return xkb_state_unref(state); }
};