From 184e53e5c2aa87c9f85ec985a3ee086519f3582a Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 24 May 2021 14:16:14 +0200 Subject: [PATCH] inputmethod: Make sure we send a state commit Detach from the serials that the client send us, since they don't really matter to the input method and track our own. Also issue a commit state whenever we adopt a new input context. This can happen for reasons that don't come from the client, like for example the input method has just been enabled. In practice, this solves an issue that we can easily see with maliit where it would be left in a half-initialised state and would show autocorrection fields on terminal applications when unnecessary and possibly similar problems every now and then. --- src/inputmethod.cpp | 8 ++------ src/inputmethod.h | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index 7b9bbf6e9e..fe3fe58689 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -230,6 +230,7 @@ void InputMethod::textInputInterfaceV2StateUpdated(quint32 serial, KWaylandServe if (!m_enabled) { return; } + Q_UNUSED(serial); auto t2 = waylandServer()->seat()->textInputV2(); auto inputContext = waylandServer()->inputMethod()->context(); @@ -241,19 +242,13 @@ void InputMethod::textInputInterfaceV2StateUpdated(quint32 serial, KWaylandServe } switch (reason) { case KWaylandServer::TextInputV2Interface::UpdateReason::StateChange: - inputContext->sendCommitState(serial); break; case KWaylandServer::TextInputV2Interface::UpdateReason::StateEnter: - waylandServer()->inputMethod()->sendActivate(); - inputContext->sendCommitState(serial); - break; case KWaylandServer::TextInputV2Interface::UpdateReason::StateFull: adoptInputMethodContext(); - inputContext->sendCommitState(serial); break; case KWaylandServer::TextInputV2Interface::UpdateReason::StateReset: inputContext->sendReset(); - inputContext->sendCommitState(serial); break; } } @@ -486,6 +481,7 @@ void InputMethod::adoptInputMethodContext() inputContext->sendSurroundingText(t3->surroundingText(), t3->surroundingTextCursorPosition(), t3->surroundingTextSelectionAnchor()); inputContext->sendContentType(t3->contentHints(), t3->contentPurpose()); } + inputContext->sendCommitState(m_serial++); connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::keysym, this, &InputMethod::keysymReceived, Qt::UniqueConnection); connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::commitString, this, &InputMethod::commitString, Qt::UniqueConnection); diff --git a/src/inputmethod.h b/src/inputmethod.h index 0104ca05b6..7e448102ae 100644 --- a/src/inputmethod.h +++ b/src/inputmethod.h @@ -91,6 +91,7 @@ private: bool m_enabled = false; bool m_active = false; + quint32 m_serial = 0; QScopedPointer m_sni; QPointer m_inputClient; QPointer m_trackedClient;