Do not commit pending text upon key event received from input method.

A common usecase for this is when preedit is not empty, but key event is
bypassed is when modifier key is pressed. For example, user may want to
send Shift+A to input method, but input method will ignore the Shift key
press and forward shift to application. This allows certain usecase if
application reacts to modifier only key event.

While it "may" causes some issue when input method decide to send key
that produce text when preedit is not empty, this does not happen in
practice and should be considered a bug on input method engine side.

(cherry picked from commit aa8c55775d)
wilder/Plasma/6.2
Weng Xuetian 1 year ago
parent 105d95bdea
commit 786ebb5e05
No known key found for this signature in database
GPG Key ID: 8E8B898CBF2412F9
  1. 4
      autotests/integration/inputmethod_test.cpp
  2. 6
      src/inputmethod.cpp

@ -863,9 +863,7 @@ void InputMethodTest::testV3AutoCommit()
zwp_input_method_context_v1_key(context, 2, timestamp, KEY_B, uint32_t(KeyboardKeyState::Pressed));
zwp_input_method_context_v1_key(context, 2, timestamp, KEY_B, uint32_t(KeyboardKeyState::Released));
QVERIFY(textInputCommitTextSpy.wait());
QCOMPARE(textInputCommitTextSpy.last()[0].toString(), "commit2");
QCOMPARE(textInputPreeditSpy.last()[0].toString(), QString());
QVERIFY(!textInputCommitTextSpy.wait());
// **************
// Mouse clicks

@ -538,9 +538,6 @@ static quint32 keysymToKeycode(quint32 sym)
void InputMethod::keysymReceived(quint32 serial, quint32 time, quint32 sym, bool pressed, quint32 modifiers)
{
if (pressed) {
commitPendingText();
}
if (auto t1 = waylandServer()->seat()->textInputV1(); t1 && t1->isEnabled()) {
if (pressed) {
t1->keysymPressed(time, sym, modifiers);
@ -767,9 +764,6 @@ void InputMethod::setPreeditString(uint32_t serial, const QString &text, const Q
void InputMethod::key(quint32 /*serial*/, quint32 /*time*/, quint32 keyCode, bool pressed)
{
if (pressed) {
commitPendingText();
}
waylandServer()->seat()->notifyKeyboardKey(keyCode,
pressed ? KeyboardKeyState::Pressed : KeyboardKeyState::Released);
}

Loading…
Cancel
Save