From 80eb461360eb39657ac21ce8070c02f071884e9a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jun 2011 10:01:14 +0200 Subject: ibus IM support for the xcb backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test code to check input methods using the ibus backend used on e.g. ubuntu. The IM code is not very sophisticated, but enough to test that things are working. Reviewed-by: Jørgen Lind --- src/plugins/platforms/xcb/qxcbintegration.cpp | 17 +++++++++++++++++ src/plugins/platforms/xcb/qxcbintegration.h | 4 ++++ src/plugins/platforms/xcb/qxcbkeyboard.cpp | 11 +++++++++++ src/plugins/platforms/xcb/xcb.pro | 3 +++ 4 files changed, 35 insertions(+) (limited to 'src/plugins/platforms/xcb') diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 984c8afb9d..fcc17b28b2 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -71,6 +71,11 @@ #include #endif +#define XCB_USE_IBUS +#if defined(XCB_USE_IBUS) +#include "QtPlatformSupport/qibusplatforminputcontext.h" +#endif + QXcbIntegration::QXcbIntegration() : m_connection(new QXcbConnection), m_printerSupport(new QGenericUnixPrinterSupport) { @@ -79,6 +84,8 @@ QXcbIntegration::QXcbIntegration() m_fontDatabase = new QGenericUnixFontDatabase(); m_nativeInterface = new QXcbNativeInterface; + + m_inputContext = 0; } QXcbIntegration::~QXcbIntegration() @@ -141,6 +148,11 @@ QAbstractEventDispatcher *QXcbIntegration::createEventDispatcher() const { QAbstractEventDispatcher *eventDispatcher = createUnixEventDispatcher(); m_connection->setEventDispatcher(eventDispatcher); +#ifdef XCB_USE_IBUS + // A bit hacky to do this here, but we need an eventloop before we can instantiate + // the input context. + const_cast(this)->m_inputContext = new QIBusPlatformInputContext; +#endif return eventDispatcher; } @@ -318,3 +330,8 @@ QPlatformDrag *QXcbIntegration::drag() const { return m_connection->drag(); } + +QPlatformInputContext *QXcbIntegration::inputContext() const +{ + return m_inputContext; +} diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index 1f426ab4e7..a89ffc89c6 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -76,6 +76,8 @@ public: QPlatformClipboard *clipboard() const; QPlatformDrag *drag() const; + QPlatformInputContext *inputContext() const; + private: bool hasOpenGL() const; QList m_screens; @@ -84,6 +86,8 @@ private: QPlatformFontDatabase *m_fontDatabase; QPlatformNativeInterface *m_nativeInterface; QPlatformPrinterSupport *m_printerSupport; + + QPlatformInputContext *m_inputContext; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 5c034252d3..adaed53106 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -46,8 +46,14 @@ #include #include #include +#include #include +#define XCB_USE_IBUS +#if defined(XCB_USE_IBUS) +#include "QtPlatformSupport/qibusplatforminputcontext.h" +#endif + #ifndef XK_ISO_Left_Tab #define XK_ISO_Left_Tab 0xFE20 #endif @@ -1023,6 +1029,11 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod QByteArray chars; xcb_keysym_t sym = lookupString(window, state, code, type, &chars); + + QIBusPlatformInputContext *ic = static_cast(QGuiApplicationPrivate::platformIntegration()->inputContext()); + if (ic && ic->x11FilterEvent(sym, code, state, type == QEvent::KeyPress)) + return; + Qt::KeyboardModifiers modifiers; int qtcode = 0; int count = chars.count(); diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 33a7494133..4b242428fe 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -84,5 +84,8 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB CONFIG += qpa/genericunixfontdatabase +QT += dbus +LIBS += -ldbus-1 + target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target -- cgit v1.2.3