[gnome-shell/wip/wayland] st-im-text: Extract the hardware keycode via the evdev code



commit f8271ac3d400049fdb054b5ea64ab8d93ad6346e
Author: Neil Roberts <neil linux intel com>
Date:   Wed Jul 18 18:42:33 2012 +0100

    st-im-text: Extract the hardware keycode via the evdev code
    
    StImText passes the hardware keycodes from Clutter events through a
    GDK function to convert them to a keysym. When using a non-X11 input
    backend, the hardware keycodes don't necessarily match the hardware
    keycodes that X would generate so the wrong keysyms were being
    generated. This patch makes it query the evdev keycode if possible
    because the X keycodes are known to be the same as the evdev
    keycodes+8.

 src/st/st-im-text.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/st/st-im-text.c b/src/st/st-im-text.c
index e1520f4..4492e7e 100644
--- a/src/st/st-im-text.c
+++ b/src/st/st-im-text.c
@@ -271,6 +271,7 @@ key_event_to_gdk (ClutterKeyEvent *event_clutter)
   GdkDisplay *display = gdk_display_get_default ();
   GdkKeymap *keymap = gdk_keymap_get_for_display (display);
   GdkEventKey *event_gdk;
+  guint evdev_keycode;
   event_gdk = (GdkEventKey *)gdk_event_new ((event_clutter->type == CLUTTER_KEY_PRESS) ?
                                             GDK_KEY_PRESS : GDK_KEY_RELEASE);
 
@@ -282,7 +283,19 @@ key_event_to_gdk (ClutterKeyEvent *event_clutter)
    * modifier state in the low 16-bits and have the same extensions.) */
   event_gdk->state = event_clutter->modifier_state;
   event_gdk->keyval = event_clutter->keyval;
-  event_gdk->hardware_keycode = event_clutter->hardware_keycode;
+
+  /* We need the hardware_keycode that X would generate to give to
+     GDK. Under X, the hardware keycodes are the same as the evdev
+     codes + 8. I'm not sure what the 8 is for. */
+  if (clutter_input_device_keycode_to_evdev (event_clutter->device,
+                                             event_clutter->hardware_keycode,
+                                             &evdev_keycode))
+    event_gdk->hardware_keycode = evdev_keycode + 8;
+  else
+    /* If we couldn't get an evdev keycode then assuming the keycode
+       is already an X keycode might be the next best thing */
+    event_gdk->hardware_keycode = event_clutter->hardware_keycode;
+
   /* For non-proper non-XKB support, we'd need a huge cut-and-paste
    * from gdkkeys-x11.c; this is a macro that just shifts a few bits
    * out of state, so won't make the situation worse if the server



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]