summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-06-22 10:01:14 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-06-27 14:31:15 +0200
commit80eb461360eb39657ac21ce8070c02f071884e9a (patch)
tree516338ddf364ac0337271db6d15c21eca689709f /src/plugins/platforms/xcb
parent0584424d5ccc7d1e3b9aa60da46ca1db244ce470 (diff)
ibus IM support for the xcb backend
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
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp17
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp11
-rw-r--r--src/plugins/platforms/xcb/xcb.pro3
4 files changed, 35 insertions, 0 deletions
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 <QtPlatformSupport/private/qeglplatformcontext_p.h>
#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<QXcbIntegration *>(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<QPlatformScreen *> 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 <X11/keysym.h>
#include <QtGui/QWindowSystemInterface>
#include <QtCore/QTextCodec>
+#include <private/qguiapplication_p.h>
#include <stdio.h>
+#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<QIBusPlatformInputContext *>(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