9#include <QtCore/qloggingcategory.h>
10#include <QtGui/qguiapplication.h>
11#include <QtGui/private/qhighdpiscaling_p.h>
12#include <QtGui/qevent.h>
13#include <QtGui/qwindow.h>
14#include <QTextCharFormat>
23 struct ::zwp_text_input_v3 *text_input)
24 :
QtWayland::zwp_text_input_v3(text_input)
35const Qt::InputMethodQueries supportedQueries3 =
Qt::ImEnabled |
49 m_pendingPreeditString.clear();
50 m_pendingCommitString.
clear();
51 m_pendingDeleteBeforeText = 0;
52 m_pendingDeleteAfterText = 0;
62 if (m_surface != surface) {
63 qCWarning(qLcQpaWaylandTextInput()) <<
Q_FUNC_INFO <<
"Got leave event for surface" << surface <<
"focused surface" << m_surface;
67 m_currentPreeditString.clear();
82 m_pendingPreeditString.text =
text;
83 m_pendingPreeditString.cursorBegin = cursorBegin;
84 m_pendingPreeditString.cursorEnd = cursorEnd;
94 m_pendingCommitString =
text;
110 qCDebug(qLcQpaWaylandTextInput) <<
Q_FUNC_INFO <<
"with serial" << serial << m_currentSerial;
114 if (m_cursorPos != m_anchorPos && (m_pendingDeleteBeforeText != 0 || m_pendingDeleteAfterText != 0)) {
116 m_pendingDeleteBeforeText = 0;
117 m_pendingDeleteAfterText = 0;
118 m_pendingPreeditString.clear();
119 m_pendingCommitString.
clear();
132 qCDebug(qLcQpaWaylandTextInput) <<
Q_FUNC_INFO <<
"PREEDIT" << m_pendingPreeditString.text << m_pendingPreeditString.cursorBegin;
134 QList<QInputMethodEvent::Attribute> attributes;
136 if (m_pendingPreeditString.cursorBegin != -1 ||
137 m_pendingPreeditString.cursorEnd != -1) {
141 m_pendingPreeditString.text.
length(),
143 attributes.append(attribute1);
153 attributes.append(attribute2);
157 qCDebug(qLcQpaWaylandTextInput) <<
Q_FUNC_INFO <<
"DELETE" << m_pendingDeleteBeforeText << m_pendingDeleteAfterText;
162 if (m_pendingDeleteBeforeText != 0 || m_pendingDeleteAfterText != 0)
163 m_condReselection =
true;
165 event.setCommitString(m_pendingCommitString,
166 -m_pendingDeleteBeforeText,
167 m_pendingDeleteBeforeText + m_pendingDeleteAfterText);
168 m_currentPreeditString = m_pendingPreeditString;
169 m_pendingPreeditString.clear();
170 m_pendingCommitString.clear();
171 m_pendingDeleteBeforeText = 0;
172 m_pendingDeleteAfterText = 0;
175 if (serial == m_currentSerial)
183 m_pendingPreeditString.clear();
188 m_currentSerial = (m_currentSerial < UINT_MAX) ? m_currentSerial + 1U: 0U;
191 QtWayland::zwp_text_input_v3::commit();
205 auto *surface =
window->wlSurface();
206 if (!surface || (surface != m_surface))
209 queries &= supportedQueries3;
210 bool needsCommit =
false;
226 if (surfaceRect != m_cursorRect) {
227 set_cursor_rectangle(surfaceRect.x(), surfaceRect.y(), surfaceRect.width(), surfaceRect.height());
228 m_cursorRect = surfaceRect;
238 qCDebug(qLcQpaWaylandTextInput) <<
"Orginal surrounding_text from InputMethodQuery: " <<
text <<
cursor << anchor;
243 const int MAX_MESSAGE_SIZE = 4000;
248 const int selectionLength = selectionEnd - selectionStart;
251 if (selectionLength > MAX_MESSAGE_SIZE) {
253 const int length = MAX_MESSAGE_SIZE;
259 const int length = -MAX_MESSAGE_SIZE;
266 const int offset = (MAX_MESSAGE_SIZE - selectionLength) / 2;
276 qCDebug(qLcQpaWaylandTextInput) <<
"Modified surrounding_text: " <<
text <<
cursor << anchor;
281 if (m_surroundingText !=
text || m_cursorPos != cursorPos || m_anchorPos != anchorPos) {
282 qCDebug(qLcQpaWaylandTextInput) <<
"Current surrounding_text: " << m_surroundingText << m_cursorPos << m_anchorPos;
283 qCDebug(qLcQpaWaylandTextInput) <<
"New surrounding_text: " <<
text << cursorPos << anchorPos;
285 set_surrounding_text(
text, cursorPos, anchorPos);
289 if (m_condReselection) {
290 qCDebug(qLcQpaWaylandTextInput) <<
"\"commit\" is disabled when Reselection by changing focus";
291 m_condReselection =
false;
296 m_surroundingText =
text;
297 m_cursorPos = cursorPos;
298 m_anchorPos = anchorPos;
305 qCDebug(qLcQpaWaylandTextInput) << m_contentHint << contentType.
hint;
306 qCDebug(qLcQpaWaylandTextInput) << m_contentPurpose << contentType.
purpose;
308 if (m_contentHint != contentType.
hint || m_contentPurpose != contentType.
purpose) {
309 qCDebug(qLcQpaWaylandTextInput) <<
"set_content_type: " << contentType.
hint << contentType.
purpose;
310 set_content_type(contentType.
hint, contentType.
purpose);
312 m_contentHint = contentType.
hint;
313 m_contentPurpose = contentType.
purpose;
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.
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 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,...
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString mid(qsizetype position, qsizetype n=-1) const &
void clear()
Clears the contents of the string and makes it null.
QByteArray toUtf8() const &
qsizetype length() const noexcept
Returns the number of characters in this string.
void setFontUnderline(bool underline)
If underline is true, sets the text format's font to be underlined; otherwise it is displayed non-und...
~QWaylandTextInputv3() override
void zwp_text_input_v3_commit_string(const QString &text) override
Qt::LayoutDirection inputDirection() const override
QLocale locale() const override
void updateState(Qt::InputMethodQueries queries, uint32_t flags) override
void zwp_text_input_v3_enter(struct ::wl_surface *surface) override
void zwp_text_input_v3_preedit_string(const QString &text, int32_t cursor_begin, int32_t cursor_end) override
QRectF keyboardRect() const override
void zwp_text_input_v3_delete_surrounding_text(uint32_t before_length, uint32_t after_length) override
void zwp_text_input_v3_leave(struct ::wl_surface *surface) override
void setCursorInsidePreedit(int cursor) override
bool isInputPanelVisible() const override
void zwp_text_input_v3_done(uint32_t serial) override
struct wl_display * display
T toNativePixels(const T &value, const C *context)
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 convertV3(Qt::InputMethodHints hints)