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 <liang.qi@qt.io>
This commit is contained in:
Inho Lee 2025-05-15 12:37:21 +02:00
parent a25054d33d
commit 7be5b47617
2 changed files with 10 additions and 5 deletions

View File

@ -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();
}

View File

@ -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;