Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
vm_tools: sommelier: Bump text-input-extension version from 9 to 11
Browse files Browse the repository at this point in the history
BUG=None
TEST=CQ

Change-Id: I6acff04cec92edfc269dc2c8d0a8ec68f467d55d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4622502
Reviewed-by: Nic Hollingum <[email protected]>
Commit-Queue: Nic Hollingum <[email protected]>
Auto-Submit: Timothy Loh <[email protected]>
Tested-by: Timothy Loh <[email protected]>
  • Loading branch information
tim-loh authored and Chromeos LUCI committed Jun 21, 2023
1 parent 38705ce commit 20c3ff8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
39 changes: 37 additions & 2 deletions protocol/text-input-extension-unstable-v1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>

<interface name="zcr_text_input_extension_v1" version="9">
<interface name="zcr_text_input_extension_v1" version="11">
<description summary="extends text_input to support richer operations">
Allows a text_input to sends more variation of operations to support
richer features, such as set_preedit_region.
Expand Down Expand Up @@ -57,7 +57,7 @@

</interface>

<interface name="zcr_extended_text_input_v1" version="9">
<interface name="zcr_extended_text_input_v1" version="11">
<description summary="extension of text_input protocol">
The zcr_extended_text_input_v1 interface extends the text_input interface
to support more rich operations on text_input.
Expand Down Expand Up @@ -373,5 +373,40 @@
<arg name="support" type="uint" enum="surrounding_text_support" />
</request>

<!-- Version 10 -->

<request name="set_surrounding_text_offset_utf16" since="10">
<description summary="Sets surrounding text's offset">
This updates UTF-16 offset of the immediately following
text_input::set_surrounding_text.

The value will be invalidated when the next set_surrounding_text
comes (i.e., if two consecutive set_surrounding_text is called,
the second set_surrounding_text's offset should be reset to 0).

Note: unlike other APIs, this is in "UTF-16" unit for Chrome's purpose,
because there's no way to convert UTF-8 offset to UTF-16 without
the original text, while sending whole text would cause performance
concerns.
</description>
<arg name="offset_utf16" type="uint"/>
</request>

<!-- Version 11 -->

<enum name="confirm_preedit_selection_behavior" since="11">
<description summary="How the selection range is affected by confirm_preedit"></description>
<entry name="after_preedit" value="0" summary="The cursor is moved to the end of the committed preedit text, if any."/>
<entry name="unchanged" value="1" summary="The selection range is not affected at all."/>
</enum>

<event name="confirm_preedit" since="11">
<description summary="Commits the current preedit">
Commits the current preedit and modify the selection range according to selection_behavior.
Has no effect if there's no preedit text.
</description>
<arg name="selection_behavior" type="uint" enum="confirm_preedit_selection_behavior" />
</event>

</interface>
</protocol>
17 changes: 16 additions & 1 deletion sommelier-text-input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace {

// Versions supported by sommelier.
constexpr uint32_t kTextInputManagerVersion = 1;
constexpr uint32_t kTextInputExtensionVersion = 9;
constexpr uint32_t kTextInputExtensionVersion = 11;
constexpr uint32_t kTextInputX11Version = 1;

} // namespace
Expand Down Expand Up @@ -350,6 +350,8 @@ static const struct zcr_extended_text_input_v1_interface
ForwardRequest<zcr_extended_text_input_v1_set_focus_reason>,
ForwardRequest<zcr_extended_text_input_v1_set_input_type>,
ForwardRequest<zcr_extended_text_input_v1_set_surrounding_text_support>,
ForwardRequest<
zcr_extended_text_input_v1_set_surrounding_text_offset_utf16>,
};

static void sl_extended_text_input_set_preedit_region(
Expand Down Expand Up @@ -420,13 +422,26 @@ static void sl_extended_text_input_set_virtual_keyboard_occluded_bounds(
host->resource, x, y, width, height);
}

static void sl_extended_text_input_confirm_preedit(
void* data,
struct zcr_extended_text_input_v1* extended_text_input,
uint32_t selection_behaviour) {
struct sl_host_extended_text_input* host =
static_cast<sl_host_extended_text_input*>(
zcr_extended_text_input_v1_get_user_data(extended_text_input));

zcr_extended_text_input_v1_send_confirm_preedit(host->resource,
selection_behaviour);
}

static const struct zcr_extended_text_input_v1_listener
sl_extended_text_input_listener = {
sl_extended_text_input_set_preedit_region,
sl_extended_text_input_clear_grammar_fragments,
sl_extended_text_input_add_grammar_fragment,
sl_extended_text_input_set_autocorrect_range,
sl_extended_text_input_set_virtual_keyboard_occluded_bounds,
sl_extended_text_input_confirm_preedit,
};

static void sl_destroy_host_extended_text_input(struct wl_resource* resource) {
Expand Down

0 comments on commit 20c3ff8

Please sign in to comment.