Implemnt preedit_styling for text input v2.

This commit is contained in:
Weng Xuetian 2021-12-19 02:02:06 -08:00
parent a711f90a69
commit 3ef4f994fa
3 changed files with 29 additions and 0 deletions

View file

@ -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);

View file

@ -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.
*

View file

@ -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);