1
0
Fork 0

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
This commit is contained in:
Rui Matos 2014-03-06 15:12:25 +01:00
parent 5cc6becb63
commit 3502cfba34

View file

@ -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)