From 62f4289cdea6aa6f6e84661ab4889cb361079b53 Mon Sep 17 00:00:00 2001 From: Inho Lee Date: Thu, 3 Oct 2024 09:51:03 +0200 Subject: [PATCH] textInputV3: Prevent recursive update calls If a 'done' which the compositor sends doesn't make any update in the client side, an additional event and updates will be skipped. Fixes: QTBUG-126275 Pick-to: 6.8 Change-Id: I86bebb3cc645f46ec2bfc6ef587ff86b76d44c9e Reviewed-by: David Edmundson Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/wayland/qwaylandtextinputv3.cpp | 8 ++++++++ src/plugins/platforms/wayland/qwaylandtextinputv3_p.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandtextinputv3.cpp b/src/plugins/platforms/wayland/qwaylandtextinputv3.cpp index bb449c9d60d..d98a7a5fca9 100644 --- a/src/plugins/platforms/wayland/qwaylandtextinputv3.cpp +++ b/src/plugins/platforms/wayland/qwaylandtextinputv3.cpp @@ -129,6 +129,14 @@ void QWaylandTextInputv3::zwp_text_input_v3_done(uint32_t serial) return; } + if ((m_pendingPreeditString == m_currentPreeditString) + && (m_pendingCommitString.isEmpty() && m_pendingDeleteBeforeText == 0 + && m_pendingDeleteAfterText == 0)) { + // Current done doesn't need additional updates + m_pendingPreeditString.clear(); + return; + } + qCDebug(qLcQpaWaylandTextInput) << Q_FUNC_INFO << "PREEDIT" << m_pendingPreeditString.text << m_pendingPreeditString.cursorBegin; QList attributes; diff --git a/src/plugins/platforms/wayland/qwaylandtextinputv3_p.h b/src/plugins/platforms/wayland/qwaylandtextinputv3_p.h index 8e32e514dd8..4ea82b1f592 100644 --- a/src/plugins/platforms/wayland/qwaylandtextinputv3_p.h +++ b/src/plugins/platforms/wayland/qwaylandtextinputv3_p.h @@ -74,6 +74,11 @@ private: cursorBegin = 0; cursorEnd = 0; } + friend bool operator==(const PreeditInfo& lhs, const PreeditInfo& rhs) { + return (lhs.text == rhs.text) + && (lhs.cursorBegin == rhs.cursorBegin) + && (lhs.cursorEnd == rhs.cursorEnd); + } }; PreeditInfo m_pendingPreeditString;