[PATCH v2 5/9] text: Add support for forwarding key events

Jan Arne Petersen jpetersen at openismus.com
Thu Nov 15 02:29:49 PST 2012


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

Allow an input method to forward (unfiltered) key and modifier events
from the hardware keyboard to the client.

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

diff --git a/protocol/input-method.xml b/protocol/input-method.xml
index 3418c0c..d680dba 100644
--- a/protocol/input-method.xml
+++ b/protocol/input-method.xml
@@ -76,6 +76,19 @@
       </description>
        <arg name="keyboard" type="new_id" interface="wl_keyboard"/>
     </request>
+    <request name="key">
+      <arg name="serial" type="uint"/>
+      <arg name="time" type="uint"/>
+      <arg name="key" type="uint"/>
+      <arg name="state" type="uint"/>
+    </request>
+    <request name="modifiers">
+      <arg name="serial" type="uint"/>
+      <arg name="mods_depressed" type="uint"/>
+      <arg name="mods_latched" type="uint"/>
+      <arg name="mods_locked" type="uint"/>
+      <arg name="group" type="uint"/>
+    </request>
     <event name="surrounding_text">
       <description summary="surrounding text event">
         The plain surrounding text around the input position. Cursor is the
diff --git a/src/text-backend.c b/src/text-backend.c
index 3799adb..badd432 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -444,13 +444,52 @@ input_method_context_grab_keyboard(struct wl_client *client,
 	wl_keyboard_start_grab(keyboard, &context->grab);
 }
 
+static void
+input_method_context_key(struct wl_client *client,
+			 struct wl_resource *resource,
+			 uint32_t serial,
+			 uint32_t time,
+			 uint32_t key,
+			 uint32_t state_w)
+{
+	struct input_method_context *context = resource->data;
+	struct weston_seat *seat = context->input_method->seat;
+	struct wl_keyboard *keyboard = seat->seat.keyboard;
+	struct wl_keyboard_grab *default_grab = &keyboard->default_grab;
+
+	default_grab->interface->key(default_grab, time, key, state_w);
+}
+
+static void
+input_method_context_modifiers(struct wl_client *client,
+			       struct wl_resource *resource,
+			       uint32_t serial,
+			       uint32_t mods_depressed,
+			       uint32_t mods_latched,
+			       uint32_t mods_locked,
+			       uint32_t group)
+{
+	struct input_method_context *context = resource->data;
+
+	struct weston_seat *seat = context->input_method->seat;
+	struct wl_keyboard *keyboard = seat->seat.keyboard;
+	struct wl_keyboard_grab *default_grab = &keyboard->default_grab;
+
+	default_grab->interface->modifiers(default_grab,
+					   serial, mods_depressed,
+					   mods_latched, mods_locked,
+					   group);
+}
+
 static const struct input_method_context_interface input_method_context_implementation = {
 	input_method_context_destroy,
 	input_method_context_commit_string,
 	input_method_context_preedit_string,
 	input_method_context_delete_surrounding_text,
 	input_method_context_keysym,
-	input_method_context_grab_keyboard
+	input_method_context_grab_keyboard,
+	input_method_context_key,
+	input_method_context_modifiers
 };
 
 static void
-- 
1.7.11.7



More information about the wayland-devel mailing list