[PATCH 1/3] text: add support for invoke_action request

Jan Arne Petersen jpetersen at openismus.com
Mon Dec 3 14:10:56 PST 2012


From: Jan Arne Petersen <jpetersen at openismus.com>

Add a request to be called by the client when the word currently being
composed is tapped by the user. Input methods often use this information
to offer more word suggestions to the user.

Signed-off-by: Jan Arne Petersen <jpetersen at openismus.com>
---
 protocol/input-method.xml |  4 ++++
 protocol/text.xml         |  4 ++++
 src/text-backend.c        | 19 ++++++++++++++++++-
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/protocol/input-method.xml b/protocol/input-method.xml
index a57fabd..d23b0b8 100644
--- a/protocol/input-method.xml
+++ b/protocol/input-method.xml
@@ -127,6 +127,10 @@
       <arg name="hint" type="uint"/>
       <arg name="purpose" type="uint"/>
     </event>
+    <event name="invoke_action">
+      <arg name="button" type="uint"/>
+      <arg name="index" type="uint"/>
+    </event>
   </interface>
 
   <interface name="input_method" version="1">
diff --git a/protocol/text.xml b/protocol/text.xml
index 448584a..1d2fef4 100644
--- a/protocol/text.xml
+++ b/protocol/text.xml
@@ -119,6 +119,10 @@
       <arg name="hint" type="uint"/>
       <arg name="purpose" type="uint"/>
     </request>
+    <request name="invoke_action">
+      <arg name="button" type="uint"/>
+      <arg name="index" type="uint"/>
+    </request>
     <event name="commit_string">
       <description summary="commit">
         Notify when text should be inserted into the editor widget. The text
diff --git a/src/text-backend.c b/src/text-backend.c
index d074347..e0b8b7d 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -248,6 +248,22 @@ text_model_set_content_type(struct wl_client *client,
 	}
 }
 
+static void
+text_model_invoke_action(struct wl_client *client,
+			 struct wl_resource *resource,
+			 uint32_t button,
+			 uint32_t index)
+{
+	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_invoke_action(&input_method->context->resource, button, index);
+	}
+}
+
 static const struct text_model_interface text_model_implementation = {
 	text_model_set_surrounding_text,
 	text_model_activate,
@@ -255,7 +271,8 @@ static const struct text_model_interface text_model_implementation = {
 	text_model_reset,
 	text_model_set_micro_focus,
 	text_model_set_preedit,
-	text_model_set_content_type
+	text_model_set_content_type,
+	text_model_invoke_action
 };
 
 static void text_model_factory_create_text_model(struct wl_client *client,
-- 
1.7.11.7



More information about the wayland-devel mailing list