text: Add language and text-direction to protocol

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
Jan Arne Petersen 12 years ago committed by Kristian Høgsberg
parent f91871980e
commit ece6b5af51
  1. 20
      clients/editor.c
  2. 28
      clients/keyboard.c
  3. 28
      clients/weston-simple-im.c
  4. 11
      protocol/input-method.xml
  5. 36
      protocol/text.xml
  6. 46
      src/text-backend.c
  7. 20
      tests/text-test.c

@ -391,6 +391,22 @@ text_model_input_panel_state(void *data,
{ {
} }
static void
text_model_language(void *data,
struct text_model *text_model,
uint32_t serial,
const char *language)
{
}
static void
text_model_text_direction(void *data,
struct text_model *text_model,
uint32_t serial,
uint32_t direction)
{
}
static const struct text_model_listener text_model_listener = { static const struct text_model_listener text_model_listener = {
text_model_commit_string, text_model_commit_string,
text_model_preedit_string, text_model_preedit_string,
@ -402,7 +418,9 @@ static const struct text_model_listener text_model_listener = {
text_model_keysym, text_model_keysym,
text_model_enter, text_model_enter,
text_model_leave, text_model_leave,
text_model_input_panel_state text_model_input_panel_state,
text_model_language,
text_model_text_direction
}; };
static struct text_entry* static struct text_entry*

@ -492,7 +492,7 @@ button_handler(struct widget *widget,
} }
static void static void
input_method_context_surrounding_text(void *data, handle_surrounding_text(void *data,
struct input_method_context *context, struct input_method_context *context,
const char *text, const char *text,
uint32_t cursor, uint32_t cursor,
@ -505,7 +505,7 @@ input_method_context_surrounding_text(void *data,
} }
static void static void
input_method_context_reset(void *data, handle_reset(void *data,
struct input_method_context *context, struct input_method_context *context,
uint32_t serial) uint32_t serial)
{ {
@ -529,7 +529,7 @@ input_method_context_reset(void *data,
} }
static void static void
input_method_context_content_type(void *data, handle_content_type(void *data,
struct input_method_context *context, struct input_method_context *context,
uint32_t hint, uint32_t hint,
uint32_t purpose) uint32_t purpose)
@ -541,7 +541,7 @@ input_method_context_content_type(void *data,
} }
static void static void
input_method_context_invoke_action(void *data, handle_invoke_action(void *data,
struct input_method_context *context, struct input_method_context *context,
uint32_t button, uint32_t button,
uint32_t index) uint32_t index)
@ -555,7 +555,7 @@ input_method_context_invoke_action(void *data,
} }
static void static void
input_method_context_commit(void *data, handle_commit(void *data,
struct input_method_context *context) struct input_method_context *context)
{ {
struct virtual_keyboard *keyboard = data; struct virtual_keyboard *keyboard = data;
@ -573,12 +573,20 @@ input_method_context_commit(void *data,
widget_schedule_redraw(keyboard->widget); widget_schedule_redraw(keyboard->widget);
} }
static void
handle_preferred_language(void *data,
struct input_method_context *context,
const char *language)
{
}
static const struct input_method_context_listener input_method_context_listener = { static const struct input_method_context_listener input_method_context_listener = {
input_method_context_surrounding_text, handle_surrounding_text,
input_method_context_reset, handle_reset,
input_method_context_content_type, handle_content_type,
input_method_context_invoke_action, handle_invoke_action,
input_method_context_commit handle_commit,
handle_preferred_language
}; };
static void static void

@ -101,7 +101,7 @@ static const uint32_t ignore_keys_on_compose[] = {
}; };
static void static void
input_method_context_surrounding_text(void *data, handle_surrounding_text(void *data,
struct input_method_context *context, struct input_method_context *context,
const char *text, const char *text,
uint32_t cursor, uint32_t cursor,
@ -111,7 +111,7 @@ input_method_context_surrounding_text(void *data,
} }
static void static void
input_method_context_reset(void *data, handle_reset(void *data,
struct input_method_context *context, struct input_method_context *context,
uint32_t serial) uint32_t serial)
{ {
@ -125,7 +125,7 @@ input_method_context_reset(void *data,
} }
static void static void
input_method_context_content_type(void *data, handle_content_type(void *data,
struct input_method_context *context, struct input_method_context *context,
uint32_t hint, uint32_t hint,
uint32_t purpose) uint32_t purpose)
@ -133,7 +133,7 @@ input_method_context_content_type(void *data,
} }
static void static void
input_method_context_invoke_action(void *data, handle_invoke_action(void *data,
struct input_method_context *context, struct input_method_context *context,
uint32_t button, uint32_t button,
uint32_t index) uint32_t index)
@ -141,17 +141,25 @@ input_method_context_invoke_action(void *data,
} }
static void static void
input_method_context_commit(void *data, handle_commit(void *data,
struct input_method_context *context) struct input_method_context *context)
{ {
} }
static void
handle_preferred_language(void *data,
struct input_method_context *context,
const char *language)
{
}
static const struct input_method_context_listener input_method_context_listener = { static const struct input_method_context_listener input_method_context_listener = {
input_method_context_surrounding_text, handle_surrounding_text,
input_method_context_reset, handle_reset,
input_method_context_content_type, handle_content_type,
input_method_context_invoke_action, handle_invoke_action,
input_method_context_commit handle_commit,
handle_preferred_language
}; };
static void static void

@ -113,6 +113,14 @@
<arg name="mods_locked" type="uint"/> <arg name="mods_locked" type="uint"/>
<arg name="group" type="uint"/> <arg name="group" type="uint"/>
</request> </request>
<request name="language">
<arg name="serial" type="uint"/>
<arg name="language" type="string"/>
</request>
<request name="text_direction">
<arg name="serial" type="uint"/>
<arg name="direction" type="uint"/>
</request>
<event name="surrounding_text"> <event name="surrounding_text">
<description summary="surrounding text event"> <description summary="surrounding text event">
The plain surrounding text around the input position. Cursor is the The plain surrounding text around the input position. Cursor is the
@ -136,6 +144,9 @@
<arg name="index" type="uint"/> <arg name="index" type="uint"/>
</event> </event>
<event name="commit"/> <event name="commit"/>
<event name="preferred_language">
<arg name="language" type="string"/>
</event>
</interface> </interface>
<interface name="input_method" version="1"> <interface name="input_method" version="1">

@ -150,6 +150,18 @@
Requests input panels (virtual keyboard) to hide. Requests input panels (virtual keyboard) to hide.
</description> </description>
</request> </request>
<request name="set_preferred_language">
<description summary="sets preferred language">
Sets a specific language. This allows for example a virtual keyboard to
show a language specific layout. The "language" argument is a RFC-3066
format language tag.
It could be used for example in a word processor to indicate language of
currently edited document or in an instant message application which tracks
languages of contacts.
</description>
<arg name="language" type="string"/>
</request>
<event name="commit_string"> <event name="commit_string">
<description summary="commit"> <description summary="commit">
Notify when text should be inserted into the editor widget. The text Notify when text should be inserted into the editor widget. The text
@ -272,6 +284,30 @@
</description> </description>
<arg name="state" type="uint"/> <arg name="state" type="uint"/>
</event> </event>
<event name="language">
<description summary="language">
Sets the language of the input text. The "language" argument is a RFC-3066
format language tag.
</description>
<arg name="serial" type="uint"/>
<arg name="language" type="string"/>
</event>
<enum name="text_direction">
<entry name="auto" value="0" summary="automatic text direction based on text and language"/>
<entry name="ltr" value="1" summary="left-to-right"/>
<entry name="rtl" value="2" summary="right-to-left"/>
</enum>
<event name="text_direction">
<description summary="text direction">
Sets the text direction of input text.
It is mainly needed for showing input cursor on correct side of the
editor when there is no input yet done and making sure neutral
direction text is laid out properly.
</description>
<arg name="serial" type="uint"/>
<arg name="direction" type="uint"/>
</event>
</interface> </interface>
<interface name="text_model_factory" version="1"> <interface name="text_model_factory" version="1">

@ -300,6 +300,22 @@ text_model_hide_input_panel(struct wl_client *client,
wl_signal_emit(&ec->hide_input_panel_signal, ec); wl_signal_emit(&ec->hide_input_panel_signal, ec);
} }
static void
text_model_set_preferred_language(struct wl_client *client,
struct wl_resource *resource,
const char *language)
{
struct text_model *text_model = resource->data;
struct input_method *input_method, *next;
wl_list_for_each_safe(input_method, next, &text_model->input_methods, link) {
if (!input_method->context)
continue;
input_method_context_send_preferred_language(&input_method->context->resource,
language);
}
}
static const struct text_model_interface text_model_implementation = { static const struct text_model_interface text_model_implementation = {
text_model_set_surrounding_text, text_model_set_surrounding_text,
text_model_activate, text_model_activate,
@ -310,7 +326,8 @@ static const struct text_model_interface text_model_implementation = {
text_model_invoke_action, text_model_invoke_action,
text_model_commit, text_model_commit,
text_model_show_input_panel, text_model_show_input_panel,
text_model_hide_input_panel text_model_hide_input_panel,
text_model_set_preferred_language
}; };
static void text_model_factory_create_text_model(struct wl_client *client, static void text_model_factory_create_text_model(struct wl_client *client,
@ -601,6 +618,29 @@ input_method_context_modifiers(struct wl_client *client,
group); group);
} }
static void
input_method_context_language(struct wl_client *client,
struct wl_resource *resource,
uint32_t serial,
const char *language)
{
struct input_method_context *context = resource->data;
text_model_send_language(&context->model->resource, serial, language);
}
static void
input_method_context_text_direction(struct wl_client *client,
struct wl_resource *resource,
uint32_t serial,
uint32_t direction)
{
struct input_method_context *context = resource->data;
text_model_send_text_direction(&context->model->resource, serial, direction);
}
static const struct input_method_context_interface input_method_context_implementation = { static const struct input_method_context_interface input_method_context_implementation = {
input_method_context_destroy, input_method_context_destroy,
input_method_context_commit_string, input_method_context_commit_string,
@ -613,7 +653,9 @@ static const struct input_method_context_interface input_method_context_implemen
input_method_context_keysym, input_method_context_keysym,
input_method_context_grab_keyboard, input_method_context_grab_keyboard,
input_method_context_key, input_method_context_key,
input_method_context_modifiers input_method_context_modifiers,
input_method_context_language,
input_method_context_text_direction
}; };
static void static void

@ -131,6 +131,22 @@ text_model_input_panel_state(void *data,
{ {
} }
static void
text_model_language(void *data,
struct text_model *text_model,
uint32_t serial,
const char *language)
{
}
static void
text_model_text_direction(void *data,
struct text_model *text_model,
uint32_t serial,
uint32_t direction)
{
}
static const struct text_model_listener text_model_listener = { static const struct text_model_listener text_model_listener = {
text_model_commit_string, text_model_commit_string,
text_model_preedit_string, text_model_preedit_string,
@ -142,7 +158,9 @@ static const struct text_model_listener text_model_listener = {
text_model_keysym, text_model_keysym,
text_model_enter, text_model_enter,
text_model_leave, text_model_leave,
text_model_input_panel_state text_model_input_panel_state,
text_model_language,
text_model_text_direction
}; };
TEST(text_test) TEST(text_test)

Loading…
Cancel
Save