wayland: Fix up key event translation

The is_modifier field is supposed to be set if the key
would act as a modifier, not if any modifiers are currently
active. To fix this, introduce a private
_gdk_wayland_keymap_key_is_modifier function.

At the same time, make the hardware_keycode field in key
events actually contain the hardware keycode, not a copy
of the keyval.
This commit is contained in:
Matthias Clasen 2013-04-06 10:40:56 -04:00
parent c659f892ff
commit eb9ab7aad4
3 changed files with 24 additions and 3 deletions

View File

@ -1032,10 +1032,9 @@ deliver_key_event(GdkWaylandDeviceData *device,
event->button.time = time;
event->key.state = device->modifiers;
event->key.group = 0;
event->key.hardware_keycode = sym;
event->key.hardware_keycode = key;
event->key.keyval = sym;
event->key.is_modifier = device->modifiers > 0;
event->key.is_modifier = _gdk_wayland_keymap_key_is_modifier (keymap, key);
translate_keyboard_string (&event->key);

View File

@ -432,3 +432,23 @@ struct xkb_state *_gdk_wayland_keymap_get_xkb_state (GdkKeymap *keymap)
{
return GDK_WAYLAND_KEYMAP (keymap)->xkb_state;
}
gboolean
_gdk_wayland_keymap_key_is_modifier (GdkKeymap *keymap,
guint keycode)
{
struct xkb_keymap *xkb_keymap = GDK_WAYLAND_KEYMAP (keymap)->xkb_keymap;
struct xkb_state *xkb_state;
gboolean is_modifier;
is_modifier = FALSE;
xkb_state = xkb_state_new (xkb_keymap);
if (xkb_state_update_key (xkb_state, keycode, XKB_KEY_DOWN) & XKB_STATE_MODS_EFFECTIVE)
is_modifier = TRUE;
xkb_state_unref (xkb_state);
return is_modifier;
}

View File

@ -55,6 +55,8 @@ void _gdk_wayland_keymap_update_from_fd (GdkKeymap *keymap,
uint32_t size);
struct xkb_state *_gdk_wayland_keymap_get_xkb_state (GdkKeymap *keymap);
struct xkb_keymap *_gdk_wayland_keymap_get_xkb_keymap (GdkKeymap *keymap);
gboolean _gdk_wayland_keymap_key_is_modifier (GdkKeymap *keymap,
guint keycode);
void _gdk_wayland_display_finalize_cursors (GdkWaylandDisplay *display);
void _gdk_wayland_display_update_cursors (GdkWaylandDisplay *display,