summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-04-04 21:52:12 -0400
committerMatthias Clasen <mclasen@redhat.com>2013-04-05 07:23:00 -0400
commitbe1e57db1fe8f652c321e87f53994a6e4c417d20 (patch)
treed7eaff65ccc203e7a461fd0ff2d5402cd3883b7e /gdk
parent33b9865651a81a041751750dc11579a9a35918fa (diff)
downloadgtk+-be1e57db1fe8f652c321e87f53994a6e4c417d20.tar.gz
wayland: Implement gdk_keymap_get_entries_for_keycode
Diffstat (limited to 'gdk')
-rw-r--r--gdk/wayland/gdkkeys-wayland.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/gdk/wayland/gdkkeys-wayland.c b/gdk/wayland/gdkkeys-wayland.c
index f58d1b3e35..cc692361ec 100644
--- a/gdk/wayland/gdkkeys-wayland.c
+++ b/gdk/wayland/gdkkeys-wayland.c
@@ -139,18 +139,53 @@ gdk_wayland_keymap_get_entries_for_keycode (GdkKeymap *keymap,
guint **keyvals,
gint *n_entries)
{
+ struct xkb_keymap *xkb_keymap = GDK_WAYLAND_KEYMAP (keymap)->xkb_keymap;
+ gint num_layouts, layout;
+ gint num_entries;
+ gint i;
+
+ num_layouts = xkb_keymap_num_layouts_for_key (xkb_keymap, hardware_keycode);
+
+ num_entries = 0;
+ for (layout = 0; layout < num_layouts; layout++)
+ num_entries += xkb_keymap_num_levels_for_key (xkb_keymap, hardware_keycode, layout);
+
if (n_entries)
- *n_entries = 1;
+ *n_entries = num_entries;
if (keys)
{
- *keys = g_new0 (GdkKeymapKey, 1);
+ *keys = g_new0 (GdkKeymapKey, num_entries);
(*keys)->keycode = hardware_keycode;
}
if (keyvals)
{
- *keyvals = g_new0 (guint, 1);
+ *keyvals = g_new0 (guint, num_entries);
(*keyvals)[0] = hardware_keycode;
}
+
+ i = 0;
+ for (layout = 0; layout < num_layouts; layout++)
+ {
+ gint num_levels, level;
+ num_levels = xkb_keymap_num_levels_for_key (xkb_keymap, hardware_keycode, layout);
+ for (level = 0; level < num_levels; level++)
+ {
+ const xkb_keysym_t *syms;
+ int num_syms;
+ num_syms = xkb_keymap_key_get_syms_by_level (xkb_keymap, hardware_keycode, layout, 0, &syms);
+ if (keys)
+ {
+ (*keys)[i].keycode = hardware_keycode;
+ (*keys)[i].group = layout;
+ (*keys)[i].level = level;
+ }
+ if (keyvals && num_syms > 0)
+ (*keyvals)[i] = syms[0];
+
+ i++;
+ }
+ }
+
return TRUE;
}