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

Commit

Permalink
vm_tools: sommelier: Update text-input-unstable-extension-v1.xml
Browse files Browse the repository at this point in the history
Update the supported version of zcr_text_input_extension_v1 from 4 to 9.

Also tidy up versioning logic in text_input protocols:
- Remove the std::min() when the client binds. sl_registry_bind asserts
  that the client doesn't request a newer version.
- Allow exo to broadcast older versions of text_input protocols.

BUG=b:273674108
TEST=Apply crrev.com/c/4328829 & crrev.com/c/4337525, highlight text in
gedit with autocorrect on and delete text with backspace.

Change-Id: If0e22886bfcc11f5848ac6f8f6e0c6b66f9e8f1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4402930
Reviewed-by: Nic Hollingum <[email protected]>
Commit-Queue: Nic Hollingum <[email protected]>
Commit-Queue: Timothy Loh <[email protected]>
Tested-by: Timothy Loh <[email protected]>
Auto-Submit: Timothy Loh <[email protected]>
  • Loading branch information
tim-loh authored and Chromeos LUCI committed Apr 6, 2023
1 parent 39c313f commit 6e9ecc1
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 33 deletions.
130 changes: 122 additions & 8 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="4">
<interface name="zcr_text_input_extension_v1" version="9">
<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="4">
<interface name="zcr_extended_text_input_v1" version="9">
<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 @@ -147,6 +147,7 @@
<entry name="autocapitalize_words" value="1 &lt;&lt; 8" />
<entry name="autocapitalize_sentences" value="1 &lt;&lt; 9" />
<entry name="has_been_password" value="1 &lt;&lt; 10" />
<entry name="vertical" value="1 &lt;&lt; 11" />
</enum>

<enum name="learning_mode" since="2">
Expand All @@ -155,13 +156,9 @@
<entry name="enabled" value="1" />
</enum>

<request name="set_input_type" since="2">
<request name="deprecated_set_input_type" since="2">
<description summary="Sets input type, mode and flags together">
In wayland, there's a concept that can be mapped to Chrome's
TextInputType, Mode and Flags. It can be set via
zwp_text_input::set_content_type. However, the variation is not rich
enough to represent Chrome's detailed behavior change. This API can be
used as a replacement of set_content_type.
Deprecated. Use the new set_input_type.
</description>
<arg name="input_type" type="uint" enum="input_type" />
<arg name="input_mode" type="uint" enum="input_mode" />
Expand Down Expand Up @@ -259,5 +256,122 @@
<arg name="height" type="uint" />
</request>

<!-- Version 5 -->

<event name="set_virtual_keyboard_occluded_bounds" since="5">
<description summary="Sets the virtual keyboard's occluded bounds.">
This event tells the client about the part of the virtual keyboard's
bounds that occludes the text input's window, in screen DIP coordinates.
In order for the text input to make proper use of this information, it
needs to know its window's screen DIP bounds via another interface such
as the aura-shell.

The occluded bounds may be smaller than the keyboard's visual bounds.

When the virtual keyboard is hidden or floating, empty bounds are sent,
i.e. with zero width and height.
</description>
<arg name="x" type="int"/>
<arg name="y" type="int"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
</event>

<!-- Version 6 -->

<request name="finalize_virtual_keyboard_changes" since="6">
<description summary="Finalizes the requested virtual keyboard changes.">
This request notifies the server that the client has finished making
requested changes to the virtual keyboard, and the server should update
the client with the latest virtual keyboard state. This avoids spurious
intermediate requests from causing the virtual keyboard to change state
unnecessarily.

Clients that connect to the server at this or higher versions must send
this request after it finishes sending the applicable requests. The
server is free to decide how it handles or honors this request.

As of version 6, the applicable requests are:
- zwp_text_input_v1.show_input_panel
- zwp_text_input_v1.hide_input_panel
</description>
</request>

<!-- Version 7 -->

<enum name="focus_reason_type" since="7">
<description summary="Chrome's TextInputClient::FocusReason">
This represents the reasons why the text input gets focused.
</description>
<entry name="none" value="0" />
<entry name="mouse" value="1" />
<entry name="touch" value="2" />
<entry name="pen" value="3" />
<entry name="other" value="4" />
</enum>

<request name="set_focus_reason" since="7">
<description summary="Specifies the reason of the following focus event">
Updates the reason why the following focus event is triggered.
This should be called just before text_input::activate,
and is in effect when it is called together (i.e. it is not in effect
until text_input::activate is called).

`reason` is an extended parameter providing the mode for the next
`text_input::active request`.
</description>
<arg name="reason" type="uint" enum="focus_reason_type" />
</request>

<!-- Version 8 -->

<enum name="inline_composition_support" since="8">
<description summary="Whether inline composition is supported">
Inline composition is an IME feature for certain languages (e.g. CJK)
which displays the uncommitted composition inside the input field as it
is being typed.
</description>
<entry name="unsupported" value="0" />
<entry name="supported" value="1" />
</enum>

<request name="set_input_type" since="8">
<description summary="Sets input type, mode and flags together">
Used in place of zwp_text_input::set_content_type.

Instead of hint and purpose, this API uses concepts that more closely
align with those used by Chrome.
</description>
<arg name="input_type" type="uint" enum="input_type" />
<arg name="input_mode" type="uint" enum="input_mode" />
<arg name="input_flags" type="uint" />
<arg name="learning_mode" type="uint" enum="learning_mode" />
<arg name="inline_composition_support" type="uint" enum="inline_composition_support" />
</request>

<!-- Version 9 -->

<enum name="surrounding_text_support" since="9">
<description summary="Whether surrounding text is supported" />
<entry name="unsupported" value="0" />
<entry name="supported" value="1" />
</enum>

<request name="set_surrounding_text_support" since="9">
<description summary="Sets whether surrounding text is supported">
Some clients are not able to provide surrounding text or selection.
When the server receives this request with the unsupproted enum, it
will disable functionality relying on surrounding text and avoid
sending events that depend on it like delete_surrounding_text,
set_preedit_region and cursor_position.

This request will take effect on the next 'set_content_type' or
'set_input_type' request.

By default, the server will assume surrounding text is supported.
</description>
<arg name="support" type="uint" enum="surrounding_text_support" />
</request>

</interface>
</protocol>
43 changes: 23 additions & 20 deletions 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 = 4;
constexpr uint32_t kTextInputExtensionVersion = 9;
constexpr uint32_t kTextInputX11Version = 1;

} // namespace
Expand Down Expand Up @@ -308,15 +308,14 @@ static struct zwp_text_input_manager_v1_interface

static void sl_bind_host_text_input_manager(struct wl_client* client,
void* data,
uint32_t version,
uint32_t app_version,
uint32_t id) {
struct sl_context* ctx = (struct sl_context*)data;
struct sl_text_input_manager* text_input_manager = ctx->text_input_manager;
struct sl_host_text_input_manager* host = new sl_host_text_input_manager();
host->ctx = ctx;
host->resource =
wl_resource_create(client, &zwp_text_input_manager_v1_interface,
std::min(version, kTextInputManagerVersion), id);
host->resource = wl_resource_create(
client, &zwp_text_input_manager_v1_interface, app_version, id);
wl_resource_set_implementation(host->resource,
&sl_text_input_manager_implementation, host,
sl_destroy_host_text_input_manager);
Expand All @@ -327,9 +326,10 @@ static void sl_bind_host_text_input_manager(struct wl_client* client,
zwp_text_input_manager_v1_set_user_data(host->proxy, host);
}

struct sl_global* sl_text_input_manager_global_create(struct sl_context* ctx) {
struct sl_global* sl_text_input_manager_global_create(struct sl_context* ctx,
uint32_t exo_version) {
return sl_global_create(ctx, &zwp_text_input_manager_v1_interface,
kTextInputManagerVersion, ctx,
std::min(exo_version, kTextInputManagerVersion), ctx,
sl_bind_host_text_input_manager);
}

Expand All @@ -341,10 +341,15 @@ static void sl_extended_text_input_destroy(struct wl_client* client,
static const struct zcr_extended_text_input_v1_interface
sl_extended_text_input_implementation = {
sl_extended_text_input_destroy,
ForwardRequest<zcr_extended_text_input_v1_set_input_type>,
ForwardRequest<zcr_extended_text_input_v1_deprecated_set_input_type>,
ForwardRequest<
zcr_extended_text_input_v1_set_grammar_fragment_at_cursor>,
ForwardRequest<zcr_extended_text_input_v1_set_autocorrect_info>,
ForwardRequest<
zcr_extended_text_input_v1_finalize_virtual_keyboard_changes>,
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>,
};

static void sl_extended_text_input_set_preedit_region(
Expand Down Expand Up @@ -464,17 +469,16 @@ static struct zcr_text_input_extension_v1_interface

static void sl_bind_host_text_input_extension(struct wl_client* client,
void* data,
uint32_t version,
uint32_t app_version,
uint32_t id) {
struct sl_context* ctx = (struct sl_context*)data;
struct sl_text_input_extension* text_input_extension =
ctx->text_input_extension;
struct sl_host_text_input_extension* host =
new sl_host_text_input_extension();
host->ctx = ctx;
host->resource =
wl_resource_create(client, &zcr_text_input_extension_v1_interface,
std::min(version, kTextInputExtensionVersion), id);
host->resource = wl_resource_create(
client, &zcr_text_input_extension_v1_interface, app_version, id);
wl_resource_set_implementation(host->resource,
&sl_text_input_extension_implementation, host,
sl_destroy_host_text_input_extension);
Expand All @@ -485,11 +489,11 @@ static void sl_bind_host_text_input_extension(struct wl_client* client,
zcr_text_input_extension_v1_set_user_data(host->proxy, host);
}

struct sl_global* sl_text_input_extension_global_create(
struct sl_context* ctx) {
struct sl_global* sl_text_input_extension_global_create(struct sl_context* ctx,
uint32_t exo_version) {
return sl_global_create(ctx, &zcr_text_input_extension_v1_interface,
kTextInputExtensionVersion, ctx,
sl_bind_host_text_input_extension);
std::min(exo_version, kTextInputExtensionVersion),
ctx, sl_bind_host_text_input_extension);
}

static void sl_text_input_x11_activate(wl_client* client,
Expand Down Expand Up @@ -532,14 +536,13 @@ static const struct zcr_text_input_x11_v1_interface

static void sl_bind_host_text_input_x11(struct wl_client* client,
void* data,
uint32_t version,
uint32_t app_version,
uint32_t id) {
// This exists only between sommelier and its clients and there is no proxy
// to the host. For simplicity we don't use a sl_host_text_input_x11
// type as it is not needed.
wl_resource* resource =
wl_resource_create(client, &zcr_text_input_x11_v1_interface,
std::min(version, kTextInputX11Version), id);
wl_resource* resource = wl_resource_create(
client, &zcr_text_input_x11_v1_interface, app_version, id);
wl_resource_set_implementation(resource, &sl_text_input_x11_implementation,
nullptr, nullptr);
}
Expand Down
5 changes: 3 additions & 2 deletions sommelier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ void sl_registry_handler(void* data,
assert(text_input_manager);
text_input_manager->ctx = ctx;
text_input_manager->id = id;
text_input_manager->host_global = sl_text_input_manager_global_create(ctx);
text_input_manager->host_global =
sl_text_input_manager_global_create(ctx, version);
text_input_manager->host_x11_global = sl_text_input_x11_global_create(ctx);
assert(!ctx->text_input_manager);
ctx->text_input_manager = text_input_manager;
Expand All @@ -720,7 +721,7 @@ void sl_registry_handler(void* data,
text_input_extension->ctx = ctx;
text_input_extension->id = id;
text_input_extension->host_global =
sl_text_input_extension_global_create(ctx);
sl_text_input_extension_global_create(ctx, version);
assert(!ctx->text_input_extension);
ctx->text_input_extension = text_input_extension;
#ifdef GAMEPAD_SUPPORT
Expand Down
8 changes: 5 additions & 3 deletions sommelier.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The ChromiumOS Authors.
// Copyright 2018 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -450,9 +450,11 @@ struct sl_global* sl_gtk_shell_global_create(struct sl_context* ctx);

struct sl_global* sl_drm_global_create(struct sl_context* ctx);

struct sl_global* sl_text_input_extension_global_create(struct sl_context* ctx);
struct sl_global* sl_text_input_extension_global_create(struct sl_context* ctx,
uint32_t exo_version);

struct sl_global* sl_text_input_manager_global_create(struct sl_context* ctx);
struct sl_global* sl_text_input_manager_global_create(struct sl_context* ctx,
uint32_t exo_version);

struct sl_global* sl_text_input_x11_global_create(struct sl_context* ctx);

Expand Down

0 comments on commit 6e9ecc1

Please sign in to comment.