9#include <QtCore/qloggingcategory.h>
10#include <QtGui/qguiapplication.h>
11#include <QtGui/qevent.h>
12#include <QtGui/qwindow.h>
13#include <QTextCharFormat>
22 struct ::zwp_text_input_v4 *text_input)
23 :
QtWayland::zwp_text_input_v4(text_input)
34const Qt::InputMethodQueries supportedQueries4 =
Qt::ImEnabled |
48 m_pendingPreeditString.clear();
49 m_pendingCommitString.
clear();
50 m_pendingDeleteBeforeText = 0;
51 m_pendingDeleteAfterText = 0;
61 if (m_surface != surface) {
62 qCWarning(qLcQpaWaylandTextInput()) <<
Q_FUNC_INFO <<
"Got leave event for surface" << surface <<
"focused surface" << m_surface;
70 m_currentPreeditString.clear();
86 m_pendingPreeditString.text =
text;
87 m_pendingPreeditString.cursorBegin = cursorBegin;
88 m_pendingPreeditString.cursorEnd = cursorEnd;
98 m_pendingCommitString =
text;
114 qCDebug(qLcQpaWaylandTextInput) <<
Q_FUNC_INFO <<
"with serial" << serial << m_currentSerial;
118 if (m_cursorPos != m_anchorPos && (m_pendingDeleteBeforeText != 0 || m_pendingDeleteAfterText != 0)) {
120 m_pendingDeleteBeforeText = 0;
121 m_pendingDeleteAfterText = 0;
122 m_pendingPreeditString.clear();
123 m_pendingCommitString.
clear();
136 qCDebug(qLcQpaWaylandTextInput) <<
Q_FUNC_INFO <<
"PREEDIT" << m_pendingPreeditString.text << m_pendingPreeditString.cursorBegin;
140 if (m_pendingPreeditString.cursorBegin != -1 ||
141 m_pendingPreeditString.cursorEnd != -1) {
145 m_pendingPreeditString.text.length(),
147 attributes.
append(attribute1);
152 format.setFontUnderline(
true);
156 m_pendingPreeditString.text.length(),
format);
157 attributes.
append(attribute2);
161 qCDebug(qLcQpaWaylandTextInput) <<
Q_FUNC_INFO <<
"DELETE" << m_pendingDeleteBeforeText << m_pendingDeleteAfterText;
166 if (m_pendingDeleteBeforeText != 0 || m_pendingDeleteAfterText != 0)
167 m_condReselection =
true;
169 event.setCommitString(m_pendingCommitString,
170 -m_pendingDeleteBeforeText,
171 m_pendingDeleteBeforeText + m_pendingDeleteAfterText);
172 m_currentPreeditString = m_pendingPreeditString;
173 m_pendingPreeditString.clear();
174 m_pendingCommitString.clear();
175 m_pendingDeleteBeforeText = 0;
176 m_pendingDeleteAfterText = 0;
179 if (serial == m_currentSerial)
187 m_pendingPreeditString.clear();
199 if (m_surface != surface) {
200 qCWarning(qLcQpaWaylandTextInput()) <<
Q_FUNC_INFO <<
"for surface" << surface <<
"focused surface" << m_surface;
207 m_currentSerial = (m_currentSerial < UINT_MAX) ? m_currentSerial + 1U: 0U;
210 QtWayland::zwp_text_input_v4::commit();
224 auto *surface =
window->wlSurface();
225 if (!surface || (surface != m_surface))
228 queries &= supportedQueries4;
229 bool needsCommit =
false;
244 if (surfaceRect != m_cursorRect) {
245 set_cursor_rectangle(surfaceRect.
x(), surfaceRect.
y(), surfaceRect.
width(), surfaceRect.
height());
246 m_cursorRect = surfaceRect;
256 qCDebug(qLcQpaWaylandTextInput) <<
"Orginal surrounding_text from InputMethodQuery: " <<
text <<
cursor << anchor;
261 const int MAX_MESSAGE_SIZE = 4000;
266 const int selectionLength = selectionEnd - selectionStart;
269 if (selectionLength > MAX_MESSAGE_SIZE) {
271 const int length = MAX_MESSAGE_SIZE;
277 const int length = -MAX_MESSAGE_SIZE;
284 const int offset = (MAX_MESSAGE_SIZE - selectionLength) / 2;
294 qCDebug(qLcQpaWaylandTextInput) <<
"Modified surrounding_text: " <<
text <<
cursor << anchor;
299 if (m_surroundingText !=
text || m_cursorPos != cursorPos || m_anchorPos != anchorPos) {
300 qCDebug(qLcQpaWaylandTextInput) <<
"Current surrounding_text: " << m_surroundingText << m_cursorPos << m_anchorPos;
301 qCDebug(qLcQpaWaylandTextInput) <<
"New surrounding_text: " <<
text << cursorPos << anchorPos;
303 set_surrounding_text(
text, cursorPos, anchorPos);
307 if (m_condReselection) {
308 qCDebug(qLcQpaWaylandTextInput) <<
"\"commit\" is disabled when Reselection by changing focus";
309 m_condReselection =
false;
314 m_surroundingText =
text;
315 m_cursorPos = cursorPos;
316 m_anchorPos = anchorPos;
323 qCDebug(qLcQpaWaylandTextInput) << m_contentHint << contentType.
hint;
324 qCDebug(qLcQpaWaylandTextInput) << m_contentPurpose << contentType.
purpose;
326 if (m_contentHint != contentType.
hint || m_contentPurpose != contentType.
purpose) {
327 qCDebug(qLcQpaWaylandTextInput) <<
"set_content_type: " << contentType.
hint << contentType.
purpose;
328 set_content_type(contentType.
hint, contentType.
purpose);
330 m_contentHint = contentType.
hint;
331 m_contentPurpose = contentType.
purpose;
344 qCWarning(qLcQpaWaylandTextInput) <<
"QWaylandTextInputV4: Input protocol \"text-input-unstable-v4-wip\" does not support setting cursor inside preedit. Use qt-text-input-method-unstable-v1 instead for full support of Qt input method events.";
349 qCWarning(qLcQpaWaylandTextInput) <<
"QWaylandTextInputV4: Input protocol \"text-input-unstable-v4-wip\" does not support querying input method visibility. Use qt-text-input-method-unstable-v1 instead for full support of Qt input method events.";
361 qCWarning(qLcQpaWaylandTextInput) <<
"QWaylandTextInputV4: Input protocol \"text-input-unstable-v4-wip\" does not support querying input language. Use qt-text-input-method-unstable-v1 instead for full support of Qt input method events.";
367 qCWarning(qLcQpaWaylandTextInput) <<
"QWaylandTextInputV4: Input protocol \"text-input-unstable-v4-wip\" does not support querying input direction. Use qt-text-input-method-unstable-v1 instead for full support of Qt input method events.";
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
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.
static QInputMethod * inputMethod()
returns the input method.
void append(parameter_type t)
constexpr int left() const noexcept
Returns the left margin.
constexpr int top() const noexcept
Returns the top margin.
\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.
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 &
~QWaylandTextInputv4() override
void zwp_text_input_v4_leave(struct ::wl_surface *surface) override
void zwp_text_input_v4_enter(struct ::wl_surface *surface) override
bool isInputPanelVisible() const override
QRectF keyboardRect() const override
void disableSurface(::wl_surface *surface) override
Qt::LayoutDirection inputDirection() const override
void setCursorInsidePreedit(int cursor) override
void zwp_text_input_v4_done(uint32_t serial) override
void zwp_text_input_v4_preedit_string(const QString &text, int32_t cursor_begin, int32_t cursor_end) override
void zwp_text_input_v4_delete_surrounding_text(uint32_t before_length, uint32_t after_length) override
void updateState(Qt::InputMethodQueries queries, uint32_t flags) override
void enableSurface(::wl_surface *surface) override
void zwp_text_input_v4_commit_string(const QString &text) override
QLocale locale() const override
struct wl_display * display
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLuint64 GLenum void * handle
GLenum GLuint GLenum GLsizei length
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
static QWaylandInputMethodContentType convertV4(Qt::InputMethodHints hints)