[mutter/wayland] wayland-keyboard: Split out a function to determine the evdev keycode



commit 3502cfba34bd0089d1c734500fe3d01e06fc91a7
Author: Rui Matos <tiagomatos gmail com>
Date:   Thu Mar 6 15:12:25 2014 +0100

    wayland-keyboard: Split out a function to determine the evdev keycode
    
    We will need to use this is in another place on the next commit.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722847

 src/wayland/meta-wayland-keyboard.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index 19f208b..7964b3f 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -389,21 +389,22 @@ update_pressed_keys (MetaWaylandKeyboard   *keyboard,
     }
 }
 
+static guint
+evdev_code (const ClutterKeyEvent *event)
+{
+  /* clutter-xkb-utils.c adds a fixed offset of 8 to go into XKB's
+   * range, so we do the reverse here. */
+  return event->hardware_keycode - 8;
+}
+
 gboolean
 meta_wayland_keyboard_handle_event (MetaWaylandKeyboard *keyboard,
                                     const ClutterKeyEvent *event)
 {
   gboolean is_press = event->type == CLUTTER_KEY_PRESS;
-  guint xkb_keycode, evdev_code;
   uint32_t serial;
   gboolean handled;
 
-  xkb_keycode = event->hardware_keycode;
-  if (event->device == NULL ||
-      !clutter_input_device_keycode_to_evdev (event->device,
-                                             xkb_keycode, &evdev_code))
-    evdev_code = xkb_keycode - 8; /* What everyone is doing in practice... */
-
   /* Synthetic key events are for autorepeat. Ignore those, as
    * autorepeat in Wayland is done on the client side. */
   if (event->flags & CLUTTER_EVENT_FLAG_SYNTHETIC)
@@ -411,7 +412,7 @@ meta_wayland_keyboard_handle_event (MetaWaylandKeyboard *keyboard,
 
   meta_verbose ("Handling key %s event code %d\n",
                is_press ? "press" : "release",
-               xkb_keycode);
+               event->hardware_keycode);
 
   update_pressed_keys (keyboard, evdev_code, is_press);
 
@@ -421,7 +422,7 @@ meta_wayland_keyboard_handle_event (MetaWaylandKeyboard *keyboard,
 
   handled = keyboard->grab->interface->key (keyboard->grab,
                                            event->time,
-                                           evdev_code,
+                                           evdev_code (event),
                                            is_press);
 
   if (handled)


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