[PATCH] Add api to obtain min/max keycode

Daniel Stone daniel at fooishbar.org
Thu May 9 07:39:22 PDT 2013


Hi,

On 22 April 2013 02:49, Matthias Clasen <matthias.clasen at gmail.com> wrote:
> On Sat, Apr 20, 2013 at 4:53 PM, Ran Benita <ran234 at gmail.com> wrote:
>> On Tue, Apr 09, 2013 at 09:57:29PM -0400, matthias.clasen at 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


More information about the wayland-devel mailing list