text: Add reset requets to protocol

Add a reset request to the text_model interface and a reset event to the
input_method_context interface. Use it to reset the pre-edit buffers in
the example keyboard when the cursor is moved in the example editor
client.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
dev
Jan Arne Petersen 12 years ago committed by Kristian Høgsberg
parent ce8a4433f5
commit c1e481efb1
  1. 2
      clients/editor.c
  2. 18
      clients/keyboard.c
  3. 2
      protocol/input-method.xml
  4. 2
      protocol/text.xml
  5. 15
      src/text-backend.c

@ -548,6 +548,8 @@ text_entry_set_cursor_position(struct text_entry *entry,
{
entry->cursor = text_layout_xy_to_index(entry->layout, x, y);
text_model_reset(entry->model);
if (entry->cursor >= entry->preedit_cursor) {
entry->cursor -= entry->preedit_cursor;
}

@ -303,8 +303,26 @@ input_method_context_surrounding_text(void *data,
fprintf(stderr, "Surrounding text updated: %s\n", text);
}
static void
input_method_context_reset(void *data,
struct input_method_context *context)
{
struct virtual_keyboard *keyboard = data;
fprintf(stderr, "Reset pre-edit buffer\n");
if (strlen(keyboard->preedit_string)) {
input_method_context_preedit_string(context,
"",
0);
free(keyboard->preedit_string);
keyboard->preedit_string = strdup("");
}
}
static const struct input_method_context_listener input_method_context_listener = {
input_method_context_surrounding_text,
input_method_context_reset
};
static void

@ -68,6 +68,8 @@
<arg name="cursor" type="uint"/>
<arg name="anchor" type="uint"/>
</event>
<event name="reset">
</event>
</interface>
<interface name="input_method" version="1">

@ -67,6 +67,8 @@
</description>
<arg name="seat" type="object" interface="wl_seat"/>
</request>
<request name="reset">
</request>
<request name="set_micro_focus">
<arg name="x" type="int"/>
<arg name="y" type="int"/>

@ -172,6 +172,20 @@ text_model_deactivate(struct wl_client *client,
weston_seat->input_method);
}
static void
text_model_reset(struct wl_client *client,
struct wl_resource *resource)
{
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_reset(&input_method->context->resource);
}
}
static void
text_model_set_micro_focus(struct wl_client *client,
struct wl_resource *resource,
@ -198,6 +212,7 @@ static const struct text_model_interface text_model_implementation = {
text_model_set_surrounding_text,
text_model_activate,
text_model_deactivate,
text_model_reset,
text_model_set_micro_focus,
text_model_set_preedit,
text_model_set_content_type

Loading…
Cancel
Save