7#include <QLoggingCategory>
8#include <QtGui/QGuiApplication>
9#include <QtGui/QTextCharFormat>
10#include <QtGui/QWindow>
11#include <QtCore/QVarLengthArray>
17#if QT_CONFIG(xkbcommon)
44#if QT_CONFIG(xkbcommon)
46 xkb_compose_state_reset(m_composeState);
55 inputInterface->reset();
66 inputInterface->commit();
89 inputInterface->disableSurface(currentSurface);
90 mCurrentWindow.
clear();
94 inputInterface->enableSurface(focusSurface);
109 inputInterface->setCursorInsidePreedit(cursorPostion);
120 inputInterface->showInputPanel();
131 inputInterface->hideInputPanel();
142 return inputInterface->isInputPanelVisible();
153 return inputInterface->keyboardRect();
164 return inputInterface->locale();
175 return inputInterface->inputDirection();
181#if QT_CONFIG(xkbcommon)
193 if (mCurrentWindow && mCurrentWindow->handle()) {
195 auto *surface =
static_cast<QWaylandWindow *
>(mCurrentWindow->handle())->wlSurface();
197 inputInterface->disableSurface(surface);
198 mCurrentWindow.
clear();
206 inputInterface->enableSurface(surface);
219#if QT_CONFIG(xkbcommon)
221void QWaylandInputContext::ensureInitialized()
227 qCWarning(qLcQpaInputMethods) <<
"error: xkb context has not been set on" <<
metaObject()->className();
231 m_initialized =
true;
232 const char *
const locale = setlocale(LC_CTYPE,
nullptr);
233 qCDebug(qLcQpaInputMethods) <<
"detected locale (LC_CTYPE):" <<
locale;
235 m_composeTable = xkb_compose_table_new_from_locale(m_XkbContext,
locale, XKB_COMPOSE_COMPILE_NO_FLAGS);
237 m_composeState = xkb_compose_state_new(m_composeTable, XKB_COMPOSE_STATE_NO_FLAGS);
239 if (!m_composeTable) {
240 qCWarning(qLcQpaInputMethods,
"failed to create compose table");
243 if (!m_composeState) {
244 qCWarning(qLcQpaInputMethods,
"failed to create compose state");
261 if (!m_composeTable || !m_composeState)
264 xkb_compose_state_feed(m_composeState, keyEvent->nativeVirtualKey());
266 switch (xkb_compose_state_get_status(m_composeState)) {
267 case XKB_COMPOSE_COMPOSING:
269 case XKB_COMPOSE_CANCELLED:
272 case XKB_COMPOSE_COMPOSED:
274 const int size = xkb_compose_state_get_utf8(m_composeState,
nullptr, 0);
276 xkb_compose_state_get_utf8(m_composeState,
buffer.data(),
buffer.size());
280 event.setCommitString(composedText);
282 if (!m_focusObject &&
qApp)
283 m_focusObject =
qApp->focusObject();
288 qCWarning(qLcQpaInputMethods,
"no focus object");
293 case XKB_COMPOSE_NOTHING:
296 Q_UNREACHABLE_RETURN(
false);
306#include "moc_qwaylandinputcontext_p.cpp"
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static QObject * focusObject()
Returns the QObject in currently active window that will be final receiver of events tied to focus,...
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
The QKeyEvent class describes a key event.
virtual bool isInputPanelVisible() const
Returns input panel visibility status.
bool inputMethodAccepted() const
Returns true if current focus object supports input method events.
virtual QLocale locale() const
virtual bool filterEvent(const QEvent *event)
This function can be reimplemented to filter input events.
virtual void reset()
Method to be called when input method needs to be reset.
virtual Qt::LayoutDirection inputDirection() const
virtual QRectF keyboardRect() const
This function can be reimplemented to return virtual keyboard rectangle in currently active window co...
T * data() const noexcept
\inmodule QtCore\reentrant
\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...
QtWayland::zwp_text_input_manager_v3 * textInputManagerv3() const
QtWayland::zwp_text_input_manager_v1 * textInputManagerv1() const
QWaylandInputDevice * defaultInputDevice() const
QtWayland::zwp_text_input_manager_v2 * textInputManagerv2() const
void hideInputPanel() override
Request to hide input panel.
QRectF keyboardRect() const override
This function can be reimplemented to return virtual keyboard rectangle in currently active window co...
void reset() override
Method to be called when input method needs to be reset.
~QWaylandInputContext() override
void showInputPanel() override
Request to show input panel.
Qt::LayoutDirection inputDirection() const override
void invokeAction(QInputMethod::Action, int cursorPosition) override
Called when the word currently being composed in the input item is tapped by the user.
void setFocusObject(QObject *object) override
This virtual method gets called to notify updated focus to object.
bool isValid() const override
Returns input context validity.
bool isInputPanelVisible() const override
Returns input panel visibility status.
void update(Qt::InputMethodQueries) override
Notification on editor updates.
QLocale locale() const override
::wl_surface * wlSurface() const
struct wl_display * display
Combined button and popup list for selecting options.
::wl_surface * surfaceForWindow(QWindow *window)
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
static void ensureInitialized()
GLenum GLuint GLintptr GLsizeiptr size
[1]
obj metaObject() -> className()