From 3ef4f994fab0dfda58c593a03a2cb39a062dc321 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Sun, 19 Dec 2021 02:02:06 -0800 Subject: [PATCH] Implemnt preedit_styling for text input v2. --- src/wayland/textinput_v2_interface.cpp | 17 +++++++++++++++++ src/wayland/textinput_v2_interface.h | 11 +++++++++++ src/wayland/textinput_v2_interface_p.h | 1 + 3 files changed, 29 insertions(+) diff --git a/src/wayland/textinput_v2_interface.cpp b/src/wayland/textinput_v2_interface.cpp index 004567ee7b..c5d43f1ae6 100644 --- a/src/wayland/textinput_v2_interface.cpp +++ b/src/wayland/textinput_v2_interface.cpp @@ -180,6 +180,18 @@ void TextInputV2InterfacePrivate::preEdit(const QString &text, const QString &co } } +void TextInputV2InterfacePrivate::preEditStyling(uint32_t index, uint32_t length, uint32_t style) +{ + if (!surface) { + return; + } + + const auto clientResources = textInputsForClient(surface->client()); + for (auto resource : clientResources) { + send_preedit_styling(resource->handle, index, length, style); + } +} + void TextInputV2InterfacePrivate::commitString(const QString &text) { if (!surface) { @@ -444,6 +456,11 @@ void TextInputV2Interface::preEdit(const QString &text, const QString &commit) d->preEdit(text, commit); } +void TextInputV2Interface::preEditStyling(uint32_t index, uint32_t length, uint32_t style) +{ + d->preEditStyling(index, length, style); +} + void TextInputV2Interface::commitString(const QString &text) { d->commitString(text); diff --git a/src/wayland/textinput_v2_interface.h b/src/wayland/textinput_v2_interface.h index f0c3530b22..5481f078b0 100644 --- a/src/wayland/textinput_v2_interface.h +++ b/src/wayland/textinput_v2_interface.h @@ -169,6 +169,17 @@ public: */ void setPreEditCursor(qint32 index); + /** + * Sets the style for a range of text for the composing text (as byte offset). + * + * The Client applies the @p index together with {@link preEdit}. + * @param index The position relative to the start of the composing text + * @param length The length of the style to apply on + * @param style style flag + * @see preEdit + */ + void preEditStyling(uint32_t index, uint32_t length, uint32_t style); + /** * Notify when the text around the current cursor position should be deleted. * diff --git a/src/wayland/textinput_v2_interface_p.h b/src/wayland/textinput_v2_interface_p.h index 1498989e75..f39a549b21 100644 --- a/src/wayland/textinput_v2_interface_p.h +++ b/src/wayland/textinput_v2_interface_p.h @@ -37,6 +37,7 @@ public: void sendEnter(SurfaceInterface *surface, quint32 serial); void sendLeave(quint32 serial, SurfaceInterface *surface); void preEdit(const QString &text, const QString &commit); + void preEditStyling(uint32_t index, uint32_t length, uint32_t style); void commitString(const QString &text); void deleteSurroundingText(quint32 beforeLength, quint32 afterLength); void setTextDirection(Qt::LayoutDirection direction);