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>
This commit is contained in:
parent
f255165bd4
commit
0eabcaafae
@ -558,6 +558,8 @@ text_entry_update(struct text_entry *entry)
|
|||||||
entry->text,
|
entry->text,
|
||||||
entry->cursor,
|
entry->cursor,
|
||||||
entry->anchor);
|
entry->anchor);
|
||||||
|
|
||||||
|
text_model_commit(entry->model);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -45,6 +45,7 @@ struct virtual_keyboard {
|
|||||||
uint32_t serial;
|
uint32_t serial;
|
||||||
uint32_t content_hint;
|
uint32_t content_hint;
|
||||||
uint32_t content_purpose;
|
uint32_t content_purpose;
|
||||||
|
char *surrounding_text;
|
||||||
struct window *window;
|
struct window *window;
|
||||||
struct widget *widget;
|
struct widget *widget;
|
||||||
};
|
};
|
||||||
@ -496,17 +497,9 @@ input_method_context_surrounding_text(void *data,
|
|||||||
uint32_t anchor)
|
uint32_t anchor)
|
||||||
{
|
{
|
||||||
struct virtual_keyboard *keyboard = data;
|
struct virtual_keyboard *keyboard = data;
|
||||||
const struct layout *layout;
|
|
||||||
|
|
||||||
layout = get_current_layout(keyboard);
|
free(keyboard->surrounding_text);
|
||||||
|
keyboard->surrounding_text = strdup(text);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -559,11 +552,31 @@ input_method_context_invoke_action(void *data,
|
|||||||
virtual_keyboard_send_preedit(keyboard, index);
|
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 = {
|
static const struct input_method_context_listener input_method_context_listener = {
|
||||||
input_method_context_surrounding_text,
|
input_method_context_surrounding_text,
|
||||||
input_method_context_reset,
|
input_method_context_reset,
|
||||||
input_method_context_content_type,
|
input_method_context_content_type,
|
||||||
input_method_context_invoke_action
|
input_method_context_invoke_action,
|
||||||
|
input_method_context_commit
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
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 = {
|
static const struct input_method_context_listener input_method_context_listener = {
|
||||||
input_method_context_surrounding_text,
|
input_method_context_surrounding_text,
|
||||||
input_method_context_reset,
|
input_method_context_reset,
|
||||||
input_method_context_content_type,
|
input_method_context_content_type,
|
||||||
input_method_context_invoke_action
|
input_method_context_invoke_action,
|
||||||
|
input_method_context_commit
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -131,6 +131,7 @@
|
|||||||
<arg name="button" type="uint"/>
|
<arg name="button" type="uint"/>
|
||||||
<arg name="index" type="uint"/>
|
<arg name="index" type="uint"/>
|
||||||
</event>
|
</event>
|
||||||
|
<event name="commit"/>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
<interface name="input_method" version="1">
|
<interface name="input_method" version="1">
|
||||||
|
@ -138,6 +138,8 @@
|
|||||||
<arg name="button" type="uint"/>
|
<arg name="button" type="uint"/>
|
||||||
<arg name="index" type="uint"/>
|
<arg name="index" type="uint"/>
|
||||||
</request>
|
</request>
|
||||||
|
<request name="commit">
|
||||||
|
</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
|
||||||
|
@ -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 = {
|
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,
|
||||||
@ -264,7 +278,8 @@ static const struct text_model_interface text_model_implementation = {
|
|||||||
text_model_reset,
|
text_model_reset,
|
||||||
text_model_set_micro_focus,
|
text_model_set_micro_focus,
|
||||||
text_model_set_content_type,
|
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,
|
static void text_model_factory_create_text_model(struct wl_client *client,
|
||||||
|
Loading…
Reference in New Issue
Block a user