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>
diff --git a/clients/keyboard.c b/clients/keyboard.c
index 50ede54..c940c6f 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -137,6 +137,20 @@
}
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,
struct input_method_context *context)
@@ -147,6 +161,9 @@
input_method_context_destroy(keyboard->context);
keyboard->context = context;
+ input_method_context_add_listener(context,
+ &input_method_context_listener,
+ keyboard);
}
static void