[PATCH 1/2] text: add assigned_seat event to the input_method interface

Philipp Brüschweiler blei42 at gmail.com
Sat Aug 11 03:12:28 PDT 2012


This event notifies the input method to which seat it is assigned. This
is necessary to distinguish multiple input methods when multiple seats
are used.
---
 protocol/text.xml  |  4 ++++
 src/text-backend.c | 23 +++++++++++++++++------
 2 Dateien geändert, 21 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

diff --git a/protocol/text.xml b/protocol/text.xml
index e73cacb..8dbb9fb 100644
--- a/protocol/text.xml
+++ b/protocol/text.xml
@@ -55,5 +55,9 @@
       <arg name="text" type="string"/>
       <arg name="index" type="uint"/>
     </request>
+
+    <event name="assigned_seat">
+      <arg name="seat" type="object" interface="wl_seat"/>
+    </event>
   </interface>
 </protocol>
diff --git a/src/text-backend.c b/src/text-backend.c
index ddeec20..9c78018 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -20,6 +20,7 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <assert.h>
 #include <stdlib.h>
 
 #include "compositor.h"
@@ -44,6 +45,7 @@ struct input_method {
 	struct wl_listener destroy_listener;
 
 	struct weston_compositor *ec;
+	struct weston_seat *seat;
 	struct text_model *model;
 
 	struct wl_list link;
@@ -257,20 +259,28 @@ bind_input_method(struct wl_client *client,
 {
 	struct input_method *input_method = data;
 	struct wl_resource *resource;
+	struct wl_resource *seat_resource;
 
 	resource = wl_client_add_object(client, &input_method_interface,
 					&input_method_implementation,
 					id, input_method);
 
-	if (input_method->input_method_binding == NULL) {
-		resource->destroy = unbind_input_method;
-		input_method->input_method_binding = resource;
+	if (input_method->input_method_binding != NULL) {
+		wl_resource_post_error(resource,
+				       WL_DISPLAY_ERROR_INVALID_OBJECT,
+				       "interface object already bound");
+		wl_resource_destroy(resource);
 		return;
 	}
 
-	wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
-			       "interface object already bound");
-	wl_resource_destroy(resource);
+	resource->destroy = unbind_input_method;
+	input_method->input_method_binding = resource;
+
+	seat_resource = wl_client_get_object_for_interface(client,
+							   &wl_seat_interface,
+							   input_method->seat);
+	assert(seat_resource);
+	input_method_send_assigned_seat(resource, seat_resource);
 }
 
 static void
@@ -325,6 +335,7 @@ input_method_create(struct weston_compositor *ec,
 	input_method = calloc(1, sizeof *input_method);
 
 	input_method->ec = ec;
+	input_method->seat = seat;
 	input_method->model = NULL;
 	input_method->focus_listener_initialized = 0;
 
-- 
1.7.11.4



More information about the wayland-devel mailing list