Track input-method contexts by identity

- deactivate only drops the context it names; one replaced by an activate
  is kept until KWin deactivates it
- Moving focus straight from one field to another ends a manual hide

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 10:13:27 +02:00
co-authored by Claude Opus 5.5
parent d44aab7772
commit 139a845151
6 changed files with 27 additions and 8 deletions
+10 -3
View File
@@ -14,9 +14,9 @@ void KWinInputMethodGlobal::zwp_input_method_v1_activate(::zwp_input_method_cont
Q_EMIT activated(context);
}
void KWinInputMethodGlobal::zwp_input_method_v1_deactivate(::zwp_input_method_context_v1 *)
void KWinInputMethodGlobal::zwp_input_method_v1_deactivate(::zwp_input_method_context_v1 *context)
{
Q_EMIT deactivated();
Q_EMIT deactivated(context);
}
KWinInputMethod::KWinInputMethod(QObject *parent)
@@ -87,13 +87,20 @@ void KWinInputMethod::setKeyPressed(quint32 keysym, bool pressed)
void KWinInputMethod::activate(::zwp_input_method_context_v1 *context)
{
m_previous = std::move(m_context);
m_context = std::make_unique<KWinInputContext>(context);
connect(m_context.get(), &KWinInputContext::contextChanged, this, &TextBackend::contextChanged);
Q_EMIT activeChanged();
}
void KWinInputMethod::deactivate()
void KWinInputMethod::deactivate(::zwp_input_method_context_v1 *context)
{
if (m_previous && m_previous->object() == context) {
m_previous.reset();
return;
}
if (!m_context || m_context->object() != context)
return;
m_context.reset();
Q_EMIT activeChanged();
Q_EMIT contextChanged();