[PATCH 5/6] Add the keymap event to input_method

Philipp Brüschweiler blei42 at gmail.com
Wed Jul 11 13:25:33 PDT 2012


---
 protocol/text.xml  | 14 +++++++++++++-
 src/text-backend.c | 12 +++++++++++-
 2 Dateien geändert, 24 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

diff --git a/protocol/text.xml b/protocol/text.xml
index e51057a..54df12e 100644
--- a/protocol/text.xml
+++ b/protocol/text.xml
@@ -1,5 +1,5 @@
 <protocol name="text">
-   <interface name="text_model" version="1">
+  <interface name="text_model" version="1">
     <request name="set_surrounding_text">
       <arg name="text" type="string"/>
     </request>
@@ -53,6 +53,18 @@
       <arg name="request_p" type="uint" description="0: false, 1: true"/>
     </request>
 
+    <!-- The following events have the same format as the ones from wl_keyboard. -->
+
+    <event name="keymap">
+      <description summary="keyboard mapping">
+        This event provides a file descriptor to the client which can be
+        memory-mapped to provide a keyboard mapping description.
+      </description>
+      <arg name="format" type="uint"/>
+      <arg name="fd" type="fd"/>
+      <arg name="size" type="uint"/>
+    </event>
+
     <event name="key">
       <description summary="key event">
 	A key was pressed or released.
diff --git a/src/text-backend.c b/src/text-backend.c
index 8681a95..a2c0ee9 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -51,6 +51,7 @@ struct input_method {
 	struct text_model *active_model;
 
 	bool request_keyboard_input_p;
+	bool keymap_sent_p;
 };
 
 static void
@@ -271,7 +272,6 @@ input_method_request_keyboard_input(struct wl_client *client,
 
 	struct input_method *input_method = resource->data;
 
-	weston_log("request keyboard!\n");
 	if ((input_method->request_keyboard_input_p != (bool) request_p)
 			&& input_method->active_model) {
 		if (request_p) {
@@ -288,6 +288,15 @@ input_method_request_keyboard_input(struct wl_client *client,
 	}
 
 	input_method->request_keyboard_input_p = request_p;
+
+	if (request_p && !input_method->keymap_sent_p) {
+		struct weston_seat *seat = input_method->ec->seat;
+		input_method_send_keymap(input_method->input_method_binding,
+					 WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
+					 seat->xkb_info.keymap_fd,
+					 seat->xkb_info.keymap_size);
+		input_method->keymap_sent_p = true;
+	}
 }
 
 static const struct input_method_interface input_method_implementation = {
@@ -299,6 +308,7 @@ static void
 clear_input_method_data(struct input_method *input_method)
 {
 	input_method->request_keyboard_input_p = false;
+	input_method->keymap_sent_p = false;
 }
 
 static void
-- 
1.7.11.1



More information about the wayland-devel mailing list