text: Fix set_surrounding_text request
Add cursor and anchor positions as arguments to the set_surrounding_text request. The cursor and anchor positions are relative to the surrounded text, so it does not make sense to have that separate. Remove the separate set_cursor_index and set_selected_text requests. Also update the corresponding event in input-method-context and add support for it in the weston example keyboard. Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
This commit is contained in:
committed by
Kristian Høgsberg
parent
c1fbcb7c38
commit
cb08f4d844
@@ -433,6 +433,11 @@ text_entry_update_layout(struct text_entry *entry)
|
||||
free(text);
|
||||
|
||||
widget_schedule_redraw(entry->widget);
|
||||
|
||||
text_model_set_surrounding_text(entry->model,
|
||||
entry->text,
|
||||
entry->cursor,
|
||||
entry->anchor);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -136,6 +136,20 @@ button_handler(struct widget *widget,
|
||||
widget_schedule_redraw(widget);
|
||||
}
|
||||
|
||||
static void
|
||||
input_method_context_surrounding_text(void *data,
|
||||
struct input_method_context *context,
|
||||
const char *text,
|
||||
uint32_t cursor,
|
||||
uint32_t anchor)
|
||||
{
|
||||
fprintf(stderr, "Surrounding text updated: %s\n", text);
|
||||
}
|
||||
|
||||
static const struct input_method_context_listener input_method_context_listener = {
|
||||
input_method_context_surrounding_text,
|
||||
};
|
||||
|
||||
static void
|
||||
input_method_activate(void *data,
|
||||
struct input_method *input_method,
|
||||
@@ -147,6 +161,9 @@ input_method_activate(void *data,
|
||||
input_method_context_destroy(keyboard->context);
|
||||
|
||||
keyboard->context = context;
|
||||
input_method_context_add_listener(context,
|
||||
&input_method_context_listener,
|
||||
keyboard);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user