Make inputcontext plugin loading a bit more generic
Add a create() method to the inputcontext factory that takes no arguments. Add a virtual isValid() to QPlatformInputContext to determine whether it actually works. Remove IBUS dependencies in the xcb code so that it can also load other plugins. Change-Id: I6345a845f48fd4b3cacf6d8652711b16835a235c Reviewed-on: http://codereview.qt-project.org/4487 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
2cdd7886bf
commit
970df64669
@ -52,6 +52,11 @@ QPlatformInputContext::~QPlatformInputContext()
|
||||
{
|
||||
}
|
||||
|
||||
bool QPlatformInputContext::isValid() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void QPlatformInputContext::reset()
|
||||
{
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ public:
|
||||
QPlatformInputContext();
|
||||
virtual ~QPlatformInputContext();
|
||||
|
||||
virtual bool isValid() const;
|
||||
|
||||
virtual void reset();
|
||||
virtual void commit();
|
||||
virtual void update(Qt::InputMethodQueries);
|
||||
|
@ -46,14 +46,13 @@
|
||||
|
||||
#include "qguiapplication.h"
|
||||
#include "qdebug.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
|
||||
(QPlatformInputContextFactoryInterface_iid, QLatin1String("/platforminputcontexts"), Qt::CaseInsensitive))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
|
||||
(QPlatformInputContextFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
|
||||
#endif
|
||||
|
||||
QStringList QPlatformInputContextFactory::keys()
|
||||
@ -79,5 +78,33 @@ QPlatformInputContext *QPlatformInputContextFactory::create(const QString& key)
|
||||
return ret;
|
||||
}
|
||||
|
||||
QPlatformInputContext *QPlatformInputContextFactory::create()
|
||||
{
|
||||
QPlatformInputContext *ic = 0;
|
||||
|
||||
QString icString = QString::fromLatin1(getenv("QT_IM_MODULE"));
|
||||
ic = create(icString);
|
||||
qDebug() << ic << ic->isValid();
|
||||
if (ic && ic->isValid())
|
||||
return ic;
|
||||
|
||||
delete ic;
|
||||
ic = 0;
|
||||
|
||||
QStringList k = keys();
|
||||
for (int i = 0; i < k.size(); ++i) {
|
||||
if (k.at(i) == icString)
|
||||
continue;
|
||||
ic = create(k.at(i));
|
||||
if (ic && ic->isValid())
|
||||
return ic;
|
||||
delete ic;
|
||||
ic = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -68,6 +68,7 @@ class QPlatformInputContextFactory
|
||||
public:
|
||||
static QStringList keys();
|
||||
static QPlatformInputContext *create(const QString &key);
|
||||
static QPlatformInputContext *create();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
QIBusPlatformInputContext();
|
||||
~QIBusPlatformInputContext();
|
||||
|
||||
Q_INVOKABLE bool isValid() const;
|
||||
bool isValid() const;
|
||||
|
||||
void invokeAction(QInputPanel::Action a, int x);
|
||||
void reset(void);
|
||||
|
@ -62,10 +62,8 @@
|
||||
#include <EGL/egl.h>
|
||||
#endif
|
||||
|
||||
#if defined(XCB_USE_IBUS)
|
||||
#include <private/qplatforminputcontextfactory_qpa_p.h>
|
||||
#include <qplatforminputcontext_qpa.h>
|
||||
#endif
|
||||
|
||||
#if defined(XCB_USE_GLX)
|
||||
#include "qglxintegration.h"
|
||||
@ -101,18 +99,7 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters)
|
||||
m_fontDatabase = new QGenericUnixFontDatabase();
|
||||
m_nativeInterface = new QXcbNativeInterface;
|
||||
|
||||
m_inputContext = 0;
|
||||
#if defined(XCB_USE_IBUS)
|
||||
QPlatformInputContext *platformInputContext = QPlatformInputContextFactory::create("ibus");
|
||||
if (platformInputContext) {
|
||||
bool retval;
|
||||
QMetaObject::invokeMethod(platformInputContext, "isValid", Qt::DirectConnection, Q_RETURN_ARG(bool, retval));
|
||||
if (retval)
|
||||
m_inputContext = platformInputContext;
|
||||
}
|
||||
if (platformInputContext && !m_inputContext)
|
||||
delete platformInputContext;
|
||||
#endif
|
||||
m_inputContext = QPlatformInputContextFactory::create();
|
||||
}
|
||||
|
||||
QXcbIntegration::~QXcbIntegration()
|
||||
|
@ -49,9 +49,7 @@
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(XCB_USE_IBUS)
|
||||
#include <qplatforminputcontext_qpa.h>
|
||||
#endif
|
||||
|
||||
#ifndef XK_ISO_Left_Tab
|
||||
#define XK_ISO_Left_Tab 0xFE20
|
||||
@ -1030,7 +1028,6 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod
|
||||
xcb_keysym_t sym = lookupString(window, state, code, type, &chars);
|
||||
|
||||
|
||||
#if defined(XCB_USE_IBUS)
|
||||
if (QObject* inputContext = QGuiApplicationPrivate::platformIntegration()->inputContext()) {
|
||||
bool retval;
|
||||
QMetaObject::invokeMethod(inputContext, "x11FilterEvent", Qt::DirectConnection,
|
||||
@ -1042,7 +1039,6 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod
|
||||
if (retval)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Qt::KeyboardModifiers modifiers;
|
||||
int qtcode = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user