5#include <QtCore/QCoreApplication>
6#include <QtCore/qvarlengtharray.h>
7#include <QtGui/QKeyEvent>
8#include <QtGui/QGuiApplication>
19 qCDebug(lcXkbCompose,
"using xkb compose input context");
24 xkb_compose_state_unref(m_composeState);
25 xkb_compose_table_unref(m_composeTable);
34 qCWarning(lcXkbCompose) <<
"error: xkb context has not been set on" <<
metaObject()->className();
41 const char *
locale = getenv(
"LC_ALL");
43 locale = getenv(
"LC_CTYPE");
50 m_composeTable = xkb_compose_table_new_from_locale(m_XkbContext,
locale, XKB_COMPOSE_COMPILE_NO_FLAGS);
52 m_composeState = xkb_compose_state_new(m_composeTable, XKB_COMPOSE_STATE_NO_FLAGS);
54 if (!m_composeTable) {
55 qCWarning(lcXkbCompose,
"failed to create compose table");
58 if (!m_composeState) {
59 qCWarning(lcXkbCompose,
"failed to create compose state");
76 if (!m_composeTable || !m_composeState)
79 xkb_compose_state_feed(m_composeState, keyEvent->nativeVirtualKey());
81 switch (xkb_compose_state_get_status(m_composeState)) {
82 case XKB_COMPOSE_COMPOSING:
84 case XKB_COMPOSE_CANCELLED:
87 case XKB_COMPOSE_COMPOSED:
89 const int size = xkb_compose_state_get_utf8(m_composeState,
nullptr, 0);
91 xkb_compose_state_get_utf8(m_composeState,
buffer.data(),
buffer.size());
95 event.setCommitString(composedText);
97 if (!m_focusObject &&
qApp)
98 m_focusObject =
qApp->focusObject();
103 qCWarning(lcXkbCompose,
"no focus object");
108 case XKB_COMPOSE_NOTHING:
111 Q_UNREACHABLE_RETURN(
false);
128 xkb_compose_state_reset(m_composeState);
138#include "moc_qcomposeplatforminputcontext.cpp"
void reset() override
Method to be called when input method needs to be reset.
bool filterEvent(const QEvent *event) override
This function can be reimplemented to filter input events.
void setFocusObject(QObject *object) override
This virtual method gets called to notify updated focus to object.
bool isValid() const override
Returns input context validity.
void update(Qt::InputMethodQueries) override
Notification on editor updates.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QKeyEvent class describes a key event.
bool inputMethodAccepted() const
Returns true if current focus object supports input method events.
virtual QLocale locale() const
virtual void update(Qt::InputMethodQueries)
Notification on editor updates.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
object setObjectName("A new object name")
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble q
#define QStringLiteral(str)
obj metaObject() -> className()