| 666 | } |
| 667 | |
| 668 | void InputMethod::setPreeditString(uint32_t serial, const QString &text, const QString &commit) |
| 669 | { |
| 670 | auto t2 = waylandServer()->seat()->textInputV2(); |
| 671 | if (t2 && t2->isEnabled()) { |
| 672 | t2->preEdit(text, commit); |
| 673 | } |
| 674 | auto t3 = waylandServer()->seat()->textInputV3(); |
| 675 | if (t3 && t3->isEnabled()) { |
| 676 | m_pendingText = commit; |
| 677 | if (!text.isEmpty()) { |
| 678 | quint32 cursor = 0, cursorEnd = 0; |
| 679 | if (preedit.cursor > 0) { |
| 680 | cursor = cursorEnd = preedit.cursor; |
| 681 | } |
| 682 | // Check if we can convert highlight style to a range of selection. |
| 683 | if (!preedit.highlightRanges.empty()) { |
| 684 | std::sort(preedit.highlightRanges.begin(), preedit.highlightRanges.end()); |
| 685 | // Check if starting point matches. |
| 686 | if (preedit.highlightRanges.front().first == cursor) { |
| 687 | quint32 end = preedit.highlightRanges.front().second; |
| 688 | bool nonContinousHighlight = false; |
| 689 | for (size_t i = 1; i < preedit.highlightRanges.size(); i++) { |
| 690 | if (end >= preedit.highlightRanges[i].first) { |
| 691 | end = std::max(end, preedit.highlightRanges[i].second); |
| 692 | } else { |
| 693 | nonContinousHighlight = true; |
| 694 | break; |
| 695 | } |
| 696 | } |
| 697 | if (!nonContinousHighlight) { |
| 698 | cursorEnd = end; |
| 699 | } |
| 700 | } |
| 701 | } |
| 702 | t3->sendPreEditString(text, cursor, cursorEnd); |
| 703 | } else { |
| 704 | t3->sendPreEditString(text, 0, 0); |
| 705 | } |
| 706 | t3->done(); |
| 707 | } |
| 708 | if (m_internalContext->isEnabled()) { |
| 709 | m_internalContext->handlePreeditText(text, preedit.cursor, preedit.cursor); |
| 710 | } |
| 711 | resetPendingPreedit(); |
| 712 | } |
| 713 | |
| 714 | void InputMethod::key(quint32 /*serial*/, quint32 time, quint32 keyCode, KeyboardKeyState state) |
| 715 | { |
nothing calls this directly
no test coverage detected