From 7be5b476177bd86d79acc14f5a9254387db34e04 Mon Sep 17 00:00:00 2001 From: Inho Lee Date: Thu, 15 May 2025 12:37:21 +0200 Subject: [PATCH] wayland textinputv3: initialize missing internal states When entering surfaces, there are some internal states which should be initialized before update. When updating states, 'commit' will always be called by needsCommit without checking flags. It amends ea32a4946ac517031b70237a831c99e02acc4361, but surface enable will make needsCommit true when 'enter'. Moved from 4cc415157d09534aede41829c5c7cf0aac578720 Fixes: QTBUG-135921 Task-number: QTBUG-131983 Change-Id: Id48d64579adc49e4ecb929a892f9dfe742578dad Reviewed-by: Liang Qi --- src/plugins/platforms/wayland/qwaylandtextinputv3.cpp | 9 +++++++-- src/plugins/platforms/wayland/qwaylandtextinputv3_p.h | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandtextinputv3.cpp b/src/plugins/platforms/wayland/qwaylandtextinputv3.cpp index 968746abb07..fbb40c2e216 100644 --- a/src/plugins/platforms/wayland/qwaylandtextinputv3.cpp +++ b/src/plugins/platforms/wayland/qwaylandtextinputv3.cpp @@ -54,6 +54,12 @@ void QWaylandTextInputv3::enableSurface(::wl_surface *surface) m_pendingCommitString.clear(); m_pendingDeleteBeforeText = 0; m_pendingDeleteAfterText = 0; + m_surroundingText.clear(); + m_cursor = 0; + m_cursorPos = 0; + m_anchorPos = 0; + m_contentHint = 0; + m_contentPurpose = 0; m_cursorRect = QRect(); enable(); @@ -385,8 +391,7 @@ void QWaylandTextInputv3::updateState(Qt::InputMethodQueries queries, uint32_t f } } - if (flags == update_state_enter - || (flags == update_state_change && needsCommit)) + if (needsCommit) commit(); } diff --git a/src/plugins/platforms/wayland/qwaylandtextinputv3_p.h b/src/plugins/platforms/wayland/qwaylandtextinputv3_p.h index 9a0d7e8a5f4..777d6c17d34 100644 --- a/src/plugins/platforms/wayland/qwaylandtextinputv3_p.h +++ b/src/plugins/platforms/wayland/qwaylandtextinputv3_p.h @@ -86,9 +86,9 @@ private: uint m_pendingDeleteAfterText = 0; // byte length QString m_surroundingText; - int m_cursor; // cursor position in QString - int m_cursorPos; // cursor position in wayland index - int m_anchorPos; // anchor position in wayland index + int m_cursor = 0; // cursor position in QString + int m_cursorPos = 0; // cursor position in wayland index + int m_anchorPos = 0; // anchor position in wayland index uint32_t m_contentHint = 0; uint32_t m_contentPurpose = 0; QRect m_cursorRect;