4#include <qpa/qplatforminputcontext.h>
11#include <QtCore/qloggingcategory.h>
12#include <QtGui/QGuiApplication>
13#include <QtGui/private/qguiapplication_p.h>
14#include <QtGui/qpa/qplatformintegration.h>
15#include <QtGui/qevent.h>
16#include <QtGui/qwindow.h>
17#include <QTextCharFormat>
30const Qt::InputMethodQueries supportedQueries2 =
Qt::ImEnabled |
40 :
QtWayland::zwp_text_input_v2(text_input)
48 wl_callback_destroy(m_resetCallback);
61 if (!m_preeditCommit.
isEmpty()) {
64 event.setCommitString(m_preeditCommit);
74const wl_callback_listener QWaylandTextInputv2::callbackListener = {
75 QWaylandTextInputv2::resetCallback
78void QWaylandTextInputv2::resetCallback(
void *
data, wl_callback *, uint32_t)
80 QWaylandTextInputv2 *self =
static_cast<QWaylandTextInputv2*
>(
data);
82 if (self->m_resetCallback) {
83 wl_callback_destroy(self->m_resetCallback);
84 self->m_resetCallback =
nullptr;
97 auto *surface =
window->wlSurface();
98 if (!surface || (surface != m_surface))
101 queries &= supportedQueries2;
130 set_content_type(contentType.
hint, contentType.
purpose);
138 set_cursor_rectangle(surfaceRect.
x(), surfaceRect.
y(), surfaceRect.
width(), surfaceRect.
height());
146 update_state(m_serial,
flags);
147 if (
flags != QtWayland::zwp_text_input_v2::update_state_change) {
149 wl_callback_destroy(m_resetCallback);
150 m_resetCallback = wl_display_sync(m_display->
wl_display());
151 wl_callback_add_listener(m_resetCallback, &QWaylandTextInputv2::callbackListener,
this);
162 return m_inputPanelVisible;
167 return m_keyboardRectangle;
177 return m_inputDirection;
192 if (m_surface != surface) {
193 qCDebug(qLcQpaInputMethods()) <<
Q_FUNC_INFO <<
"Got leave event for surface" << surface <<
"focused surface" << m_surface;
203 m_modifiersMap.
clear();
205 for (
const QByteArray &modifier : modifiersMap) {
206 if (modifier ==
"Shift")
208 else if (modifier ==
"Control")
210 else if (modifier ==
"Alt")
212 else if (modifier ==
"Mod1")
214 else if (modifier ==
"Mod4")
223 const bool inputPanelVisible = (visible == input_panel_visibility_visible);
224 if (m_inputPanelVisible != inputPanelVisible) {
225 m_inputPanelVisible = inputPanelVisible;
229 if (m_keyboardRectangle != keyboardRectangle) {
230 m_keyboardRectangle = keyboardRectangle;
237 if (m_resetCallback) {
238 qCDebug(qLcQpaInputMethods()) <<
"discard preedit_string: reset not confirmed";
267 if (m_resetCallback) {
268 qCDebug(qLcQpaInputMethods()) <<
"discard commit_string: reset not confirmed";
296#if QT_CONFIG(xkbcommon)
297 if (m_resetCallback) {
298 qCDebug(qLcQpaInputMethods()) <<
"discard keysym: reset not confirmed";
305 Qt::KeyboardModifiers qtModifiers = modifiersToQtModifiers(
modifiers);
323 if (m_resetCallback) {
324 qCDebug(qLcQpaInputMethods()) <<
"discard language: reset not confirmed";
337 if (m_resetCallback) {
338 qCDebug(qLcQpaInputMethods()) <<
"discard text_direction: reset not confirmed";
359Qt::KeyboardModifiers QWaylandTextInputv2::modifiersToQtModifiers(uint32_t
modifiers)
362 for (
int i = 0;
i < m_modifiersMap.
size(); ++
i) {
364 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.
void emitKeyboardRectChanged()
Active QPlatformInputContext is responsible for providing keyboardRectangle 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
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.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
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)
struct wl_display * wl_display() const
void zwp_text_input_v2_keysym(uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) override
~QWaylandTextInputv2() override
bool isInputPanelVisible() const override
void zwp_text_input_v2_preedit_styling(uint32_t index, uint32_t length, uint32_t style) override
void updateState(Qt::InputMethodQueries queries, uint32_t flags) override
QRectF keyboardRect() const override
void zwp_text_input_v2_delete_surrounding_text(uint32_t before_length, uint32_t after_length) override
void setCursorInsidePreedit(int cursor) override
void zwp_text_input_v2_preedit_string(const QString &text, const QString &commit) override
void zwp_text_input_v2_input_method_changed(uint32_t serial, uint32_t flags) override
void zwp_text_input_v2_language(const QString &language) override
QWaylandTextInputv2(QWaylandDisplay *display, struct ::zwp_text_input_v2 *text_input)
Qt::LayoutDirection inputDirection() const override
void zwp_text_input_v2_enter(uint32_t serial, struct ::wl_surface *surface) override
QLocale locale() const override
void zwp_text_input_v2_text_direction(uint32_t direction) override
void zwp_text_input_v2_modifiers_map(wl_array *map) override
void zwp_text_input_v2_commit_string(const QString &text) override
void zwp_text_input_v2_cursor_position(int32_t index, int32_t anchor) override
void zwp_text_input_v2_input_panel_state(uint32_t state, int32_t x, int32_t y, int32_t width, int32_t height) override
void zwp_text_input_v2_preedit_cursor(int32_t index) override
void zwp_text_input_v2_leave(uint32_t serial, struct ::wl_surface *surface) 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
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
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)