text: Split out cursor_position

Add an extra cursor_position, which also allows to change the anchor
(for slections). Change the index type to int to allow setting it before
the beginning of a commited string.

The cursor should not be moved as a direct repsonse to this event but
atomically on the next commit_string event.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
diff --git a/src/text-backend.c b/src/text-backend.c
index 00ca46e..a92aebe 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -397,12 +397,11 @@
 input_method_context_commit_string(struct wl_client *client,
 				   struct wl_resource *resource,
 				   uint32_t serial,
-				   const char *text,
-				   uint32_t index)
+				   const char *text)
 {
 	struct input_method_context *context = resource->data;
 
-	text_model_send_commit_string(&context->model->resource, serial, text, index);
+	text_model_send_commit_string(&context->model->resource, serial, text);
 }
 
 static void
@@ -454,6 +453,18 @@
 }
 
 static void
+input_method_context_cursor_position(struct wl_client *client,
+				     struct wl_resource *resource,
+				     uint32_t serial,
+				     int32_t index,
+				     int32_t anchor)
+{
+	struct input_method_context *context = resource->data;
+
+	text_model_send_cursor_position(&context->model->resource, serial, index, anchor);
+}
+
+static void
 input_method_context_modifiers_map(struct wl_client *client,
 				   struct wl_resource *resource,
 				   struct wl_array *map)
@@ -597,6 +608,7 @@
 	input_method_context_preedit_styling,
 	input_method_context_preedit_cursor,
 	input_method_context_delete_surrounding_text,
+	input_method_context_cursor_position,
 	input_method_context_modifiers_map,
 	input_method_context_keysym,
 	input_method_context_grab_keyboard,