| 503 | } |
| 504 | |
| 505 | void InputMethod::commitString(quint32 serial, const QString &text) |
| 506 | { |
| 507 | if (auto t2 = waylandServer()->seat()->textInputV2(); t2 && t2->isEnabled()) { |
| 508 | t2->commitString(text); |
| 509 | t2->setPreEditCursor(0); |
| 510 | t2->preEdit({}, {}); |
| 511 | return; |
| 512 | } else if (auto t3 = waylandServer()->seat()->textInputV3(); t3 && t3->isEnabled()) { |
| 513 | t3->sendPreEditString(QString(), 0, 0); |
| 514 | t3->commitString(text); |
| 515 | t3->done(); |
| 516 | return; |
| 517 | } else if (m_internalContext->isEnabled()) { |
| 518 | m_internalContext->handlePreeditText({}, 0, 0); |
| 519 | m_internalContext->handleCommitString(text); |
| 520 | } else { |
| 521 | // The application has no way of communicating with the input method. |
| 522 | // So instead, try to convert what we get from the input method into |
| 523 | // keycodes and send those as fake input to the client. |
| 524 | |
| 525 | const QList<xkb_keysym_t> keySyms = Xkb::textToKeySyms(text); |
| 526 | |
| 527 | // First, send all the extracted keys as pressed keys to the client. |
| 528 | for (const xkb_keysym_t &keySym : keySyms) { |
| 529 | forwardKeySym(keySym); |
| 530 | } |
| 531 | |
| 532 | // reset any modifiers to the actual state |
| 533 | input()->keyboard()->xkb()->forwardModifiers(); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | void InputMethod::forwardKeySym(int keySym) |
| 538 | { |