3#include <qpa/qplatforminputcontext.h>
10#include <QtCore/qloggingcategory.h>
11#include <QtGui/QGuiApplication>
12#include <QtGui/private/qguiapplication_p.h>
13#include <QtGui/qpa/qplatformintegration.h>
14#include <QtGui/qevent.h>
15#include <QtGui/qwindow.h>
16#include <QTextCharFormat>
29const Qt::InputMethodQueries supportedQueries1 =
Qt::ImEnabled |
39 :
QtWayland::zwp_text_input_v1(text_input)
47 wl_callback_destroy(m_resetCallback);
61 event.setCommitString(m_preeditCommit);
68const wl_callback_listener QWaylandTextInputv1::callbackListener = {
69 QWaylandTextInputv1::resetCallback
72void QWaylandTextInputv1::resetCallback(
void *
data, wl_callback *, uint32_t)
74 QWaylandTextInputv1 *self =
static_cast<QWaylandTextInputv1*
>(
data);
76 if (self->m_resetCallback) {
77 wl_callback_destroy(self->m_resetCallback);
78 self->m_resetCallback =
nullptr;
91 auto *surface =
window->wlSurface();
92 if (!surface || (surface != m_surface))
95 queries &= supportedQueries1;
124 set_content_type(contentType.
hint, contentType.
purpose);
132 set_cursor_rectangle(surfaceRect.
x(), surfaceRect.
y(), surfaceRect.
width(), surfaceRect.
height());
141 QtWayland::zwp_text_input_v1::reset();
143 commit_state(m_serial);
153 return m_inputPanelVisible;
158 return m_keyboardRectangle;
168 return m_inputDirection;
187 m_modifiersMap.
clear();
189 for (
const QByteArray &modifier : modifiersMap) {
190 if (modifier ==
"Shift")
192 else if (modifier ==
"Control")
194 else if (modifier ==
"Alt")
196 else if (modifier ==
"Mod1")
198 else if (modifier ==
"Mod4")
207 const bool inputPanelVisible = (visible == 1);
208 if (m_inputPanelVisible != inputPanelVisible) {
209 m_inputPanelVisible = inputPanelVisible;
218 if (m_resetCallback) {
219 qCDebug(qLcQpaInputMethods()) <<
"discard preedit_string: reset not confirmed";
250 if (m_resetCallback) {
251 qCDebug(qLcQpaInputMethods()) <<
"discard commit_string: reset not confirmed";
261 m_preeditCommit.
clear();
286#if QT_CONFIG(xkbcommon)
287 if (m_resetCallback) {
288 qCDebug(qLcQpaInputMethods()) <<
"discard keysym: reset not confirmed";
295 Qt::KeyboardModifiers qtModifiers = modifiersToQtModifiers(
modifiers);
315 if (m_resetCallback) {
316 qCDebug(qLcQpaInputMethods()) <<
"discard language: reset not confirmed";
331 if (m_resetCallback) {
332 qCDebug(qLcQpaInputMethods()) <<
"discard text_direction: reset not confirmed";
345Qt::KeyboardModifiers QWaylandTextInputv1::modifiersToQtModifiers(uint32_t
modifiers)
348 for (
int i = 0;
i < m_modifiersMap.
size(); ++
i) {
350 ret |= m_modifiersMap[
i];
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays.
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
Type
This enum type defines the valid event types in Qt.
static QPlatformIntegration * platformIntegration()
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.
static QInputMethod * inputMethod()
returns the input method.
qsizetype size() const noexcept
void append(parameter_type t)
constexpr int left() const noexcept
Returns the left margin.
constexpr int top() const noexcept
Returns the top margin.
void emitInputDirectionChanged(Qt::LayoutDirection newDirection)
void emitInputPanelVisibleChanged()
Active QPlatformInputContext is responsible for providing visible property to QInputMethod.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
\macro QT_RESTRICTED_CAST_FROM_ASCII
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const
Returns the number of characters in this string.
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
QByteArray toUtf8() const &
static bool handleKeyEvent(QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString &text=QString(), bool autorep=false, ushort count=1)
static QString lookupStringNoKeysymTransformations(xkb_keysym_t keysym)
static int keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers)
QRectF keyboardRect() const override
void zwp_text_input_v1_language(uint32_t serial, const QString &language) override
void zwp_text_input_v1_keysym(uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) override
QWaylandTextInputv1(QWaylandDisplay *display, struct ::zwp_text_input_v1 *text_input)
void zwp_text_input_v1_enter(struct ::wl_surface *surface) override
void zwp_text_input_v1_input_panel_state(uint32_t state) override
Qt::LayoutDirection inputDirection() const override
QLocale locale() const override
~QWaylandTextInputv1() override
bool isInputPanelVisible() const override
void zwp_text_input_v1_cursor_position(int32_t index, int32_t anchor) override
void zwp_text_input_v1_leave() override
void zwp_text_input_v1_modifiers_map(wl_array *map) override
void zwp_text_input_v1_preedit_string(uint32_t serial, const QString &text, const QString &commit) override
void zwp_text_input_v1_commit_string(uint32_t serial, const QString &text) override
void zwp_text_input_v1_delete_surrounding_text(int32_t before_length, uint32_t after_length) override
void updateState(Qt::InputMethodQueries queries, uint32_t flags) override
void zwp_text_input_v1_preedit_cursor(int32_t index) override
void zwp_text_input_v1_text_direction(uint32_t serial, uint32_t direction) override
void zwp_text_input_v1_preedit_styling(uint32_t index, uint32_t length, uint32_t style) override
void setCursorInsidePreedit(int cursor) override
EGLImageKHR int int EGLuint64KHR * modifiers
QMap< QString, QString > map
[6]
struct wl_display * display
Combined button and popup list for selecting options.
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr T qAbs(const T &t)
GLuint64 GLenum void * handle
GLenum GLuint GLenum GLsizei length
GLint GLint GLint GLint GLsizei GLsizei GLsizei GLboolean commit
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
static QWaylandInputMethodContentType convert(Qt::InputMethodHints hints)