From 6d6ce2981e569a519a631956037523020b0c2df6 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Mon, 20 Dec 2021 03:33:41 -0800 Subject: [PATCH] Add preedit styling support for text-input-v2. --- src/inputmethod.cpp | 8 ++++++++ src/inputmethod.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index 1c7e055e99..b30b85df29 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -457,6 +457,13 @@ void InputMethod::setPreeditCursor(qint32 index) } } +void InputMethod::setPreeditStyling(quint32 index, quint32 length, quint32 style) +{ + auto t2 = waylandServer()->seat()->textInputV2(); + if (t2 && t2->isEnabled()) { + t2->preEditStyling(index, length, style); + } +} void InputMethod::setPreeditString(uint32_t serial, const QString &text, const QString &commit) { @@ -524,6 +531,7 @@ void InputMethod::adoptInputMethodContext() connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::commitString, this, &InputMethod::commitString, Qt::UniqueConnection); connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::deleteSurroundingText, this, &InputMethod::deleteSurroundingText, Qt::UniqueConnection); connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::cursorPosition, this, &InputMethod::setCursorPosition, Qt::UniqueConnection); + connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditStyling, this, &InputMethod::setPreeditStyling, Qt::UniqueConnection); connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditString, this, &InputMethod::setPreeditString, Qt::UniqueConnection); connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditCursor, this, &InputMethod::setPreeditCursor, Qt::UniqueConnection); connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::keyboardGrabRequested, this, &InputMethod::installKeyboardGrab, Qt::UniqueConnection); diff --git a/src/inputmethod.h b/src/inputmethod.h index 0ba9ce4a85..e29481ada4 100644 --- a/src/inputmethod.h +++ b/src/inputmethod.h @@ -77,6 +77,7 @@ private Q_SLOTS: // inputcontext slots void setPreeditString(uint32_t serial, const QString &text, const QString &commit); + void setPreeditStyling(quint32 index, quint32 length, quint32 style); void setPreeditCursor(qint32 index); void key(quint32 serial, quint32 time, quint32 key, bool pressed); void modifiers(quint32 serial, quint32 mods_depressed, quint32 mods_latched, quint32 mods_locked, quint32 group);