Re: [PATCH] Add api to obtain min/max keycode

2013-05-09 Thread Daniel Stone
Hi,

On 22 April 2013 02:49, Matthias Clasen matthias.cla...@gmail.com wrote:
 On Sat, Apr 20, 2013 at 4:53 PM, Ran Benita ran...@gmail.com wrote:
 On Tue, Apr 09, 2013 at 09:57:29PM -0400, matthias.cla...@gmail.com wrote:
 Users of libxkbcommon need these values to iterate over all
 keycodes in the keymap.

 Can you describe the use case a bit more? Is it just to get the keysyms,
 or something more?

 Look at
 https://git.gnome.org/browse/gtk+/tree/gdk/wayland/gdkkeys-wayland.c#n388
 for an example.

Yeah, it's a perfectly reasonable thing to do, especially for shortcut
processing.

 What I'd suggest is just adding some iterator API for the keys; that'd
 be both cleaner and more extensible (e.g. to provide some further
 information on the keys). One lazy option would be to opaquely expose
 the 'struct xkb_key' object we already have internally, and add some
 accessors and first/last/prev/next/whatever. Even if not exposed by
 itself, you can find its definition in src/keymap.h and see the various
 bits of information it contains.

 Would something like that be OK?

 Seems a bit like overkill to me. Sure, xkbcommon doesn't have the 255
 keys limit that xkb has, but keyboards are not suddenly going to grow
 thousands of new keys...

Shrug.  Most people use them for simple iteration, but then again most
people already have existing iteration code which is easier to convert
to the for(min/max) form.  So I've put in both:
  - xkb_keymap_min_keycode and xkb_keymap_max_keycode have the _get_
removed but are otherwise the same
  - xkb_keymap_key_for_each calls a function taking (xkb_keymap *,
xkb_keycode_t, void *)

Does that work? If so, I'll shove them into an 0.4.0.

Cheers,
Daniel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH] Add api to obtain min/max keycode

2013-04-09 Thread matthias . clasen
From: Matthias Clasen mcla...@redhat.com

Users of libxkbcommon need these values to iterate over all
keycodes in the keymap.
---
 src/keymap.c  | 12 
 xkbcommon/xkbcommon.h | 20 
 2 files changed, 32 insertions(+)

diff --git a/src/keymap.c b/src/keymap.c
index 55000f4..14ec25f 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -484,6 +484,18 @@ err:
 return 0;
 }
 
+XKB_EXPORT xkb_keycode_t
+xkb_keymap_get_min_keycode (struct xkb_keymap *keymap)
+{
+return keymap-min_key_code;
+}
+
+XKB_EXPORT xkb_keycode_t
+xkb_keymap_get_max_keycode (struct xkb_keymap *keymap)
+{
+return keymap-max_key_code;
+}
+
 /**
  * Simple boolean specifying whether or not the key should repeat.
  */
diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h
index a2aecfb..412f429 100644
--- a/xkbcommon/xkbcommon.h
+++ b/xkbcommon/xkbcommon.h
@@ -974,6 +974,26 @@ xkb_led_index_t
 xkb_keymap_led_get_index(struct xkb_keymap *keymap, const char *name);
 
 /**
+ * Get the minimum keycode of the keymap
+ *
+ * @returns The minimum keycode of the keymap.
+ *
+ * @memberof xkb_keymap
+ */
+xkb_keycode_t
+xkb_keymap_get_min_keycode (struct xkb_keymap *keymap);
+
+/**
+ * Get the maximum keycode of the keymap
+ *
+ * @returns The maximum keycode of the keymap.
+ *
+ * @memberof xkb_keymap
+ */
+xkb_keycode_t
+xkb_keymap_get_max_keycode (struct xkb_keymap *keymap);
+
+/**
  * Determine whether a key should repeat or not.
  *
  * A keymap may specify different repeat behaviors for different keys.
-- 
1.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel