text: Add commit request

Allows for atomic state changes. Updated surrounding text, content type
and micro focus is taken into account all at once at commit.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
dev
Jan Arne Petersen 12 years ago committed by Kristian Høgsberg
parent f255165bd4
commit 0eabcaafae
  1. 2
      clients/editor.c
  2. 35
      clients/keyboard.c
  3. 9
      clients/weston-simple-im.c
  4. 1
      protocol/input-method.xml
  5. 2
      protocol/text.xml
  6. 17
      src/text-backend.c

@ -558,6 +558,8 @@ text_entry_update(struct text_entry *entry)
entry->text,
entry->cursor,
entry->anchor);
text_model_commit(entry->model);
}
static void

@ -45,6 +45,7 @@ struct virtual_keyboard {
uint32_t serial;
uint32_t content_hint;
uint32_t content_purpose;
char *surrounding_text;
struct window *window;
struct widget *widget;
};
@ -496,17 +497,9 @@ input_method_context_surrounding_text(void *data,
uint32_t anchor)
{
struct virtual_keyboard *keyboard = data;
const struct layout *layout;
layout = get_current_layout(keyboard);
fprintf(stderr, "Surrounding text updated: %s\n", text);
window_schedule_resize(keyboard->window,
layout->columns * key_width,
layout->rows * key_height);
widget_schedule_redraw(keyboard->widget);
free(keyboard->surrounding_text);
keyboard->surrounding_text = strdup(text);
}
static void
@ -559,11 +552,31 @@ input_method_context_invoke_action(void *data,
virtual_keyboard_send_preedit(keyboard, index);
}
static void
input_method_context_commit(void *data,
struct input_method_context *context)
{
struct virtual_keyboard *keyboard = data;
const struct layout *layout;
layout = get_current_layout(keyboard);
if (keyboard->surrounding_text)
fprintf(stderr, "Surrounding text updated: %s\n", keyboard->surrounding_text);
window_schedule_resize(keyboard->window,
layout->columns * key_width,
layout->rows * key_height);
widget_schedule_redraw(keyboard->widget);
}
static const struct input_method_context_listener input_method_context_listener = {
input_method_context_surrounding_text,
input_method_context_reset,
input_method_context_content_type,
input_method_context_invoke_action
input_method_context_invoke_action,
input_method_context_commit
};
static void

@ -140,11 +140,18 @@ input_method_context_invoke_action(void *data,
{
}
static void
input_method_context_commit(void *data,
struct input_method_context *context)
{
}
static const struct input_method_context_listener input_method_context_listener = {
input_method_context_surrounding_text,
input_method_context_reset,
input_method_context_content_type,
input_method_context_invoke_action
input_method_context_invoke_action,
input_method_context_commit
};
static void

@ -131,6 +131,7 @@
<arg name="button" type="uint"/>
<arg name="index" type="uint"/>
</event>
<event name="commit"/>
</interface>
<interface name="input_method" version="1">

@ -138,6 +138,8 @@
<arg name="button" type="uint"/>
<arg name="index" type="uint"/>
</request>
<request name="commit">
</request>
<event name="commit_string">
<description summary="commit">
Notify when text should be inserted into the editor widget. The text

@ -257,6 +257,20 @@ text_model_invoke_action(struct wl_client *client,
}
}
static void
text_model_commit(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_commit(&input_method->context->resource);
}
}
static const struct text_model_interface text_model_implementation = {
text_model_set_surrounding_text,
text_model_activate,
@ -264,7 +278,8 @@ static const struct text_model_interface text_model_implementation = {
text_model_reset,
text_model_set_micro_focus,
text_model_set_content_type,
text_model_invoke_action
text_model_invoke_action,
text_model_commit
};
static void text_model_factory_create_text_model(struct wl_client *client,

Loading…
Cancel
Save