[ANNOUNCE] libxkbcommon-0.4.1

Daniel Stone daniel at fooishbar.org
Mon Mar 31 12:41:39 PDT 2014


On 27 March 2014 22:41, Ran Benita <ran234 at gmail.com> wrote:

> On Thu, Mar 27, 2014 at 09:04:07PM +0100, David Herrmann wrote:
> > On Thu, Mar 27, 2014 at 8:22 PM, Ran Benita <ran234 at gmail.com> wrote:
> > > - Added two new functions, xkb_state_key_get_utf{8,32}(). They
> > >   combine the operations of xkb_state_key_get_syms() and
> > >   xkb_keysym_to_utf{8,32}(), and provide a nicer interface for it
> > >   (espcially for multiple-keysyms-per-level).
> >
> > Slightly off-topic, but looking at the code, you ignore any multi-sym
> > values (nsyms != 1). Users of that API might rely on that behavior, so
> > have we at some point defined what exactly multi-sym means? Because if
> > we add more and more APIs and if the user-base grows, we might at some
> > point be unable to make use of multi-symbol behavior. I'm still not
> > sure whether nsyms > 1 just means multiple sequential keysyms, or
> > whether they should be handled as _one_ atomic combined keysym?
> First, the reason I added these functions is that
> https://bugs.freedesktop.org/show_bug.cgi?id=75892 made it necessary, I
> would otherwise like to avoid adding new API at this point. But given
> the situation, I tried to make the best of it.
> I only ignore multiple-keysyms for the utf32 function -- I only added
> it to match the existing xkb_keysym_to_utf32() function. I don't think
> it makes sense to encode multiple-keysyms into a UTF-32 string, nobody
> uses it. A better name would be xkb_keysym_to_unicode_codepoint() or
> whatever, but I wanted to keep the existing name.
> For the utf8 function, it is handled correctly, and is actually much
> easier to use for multiple-keysyms than the old function. It builds the
> string internally and finally ensures it's valid UTF-8.
> Another advantage of adding new functions is that existing users don't
> break due to the new behavior, they must opt-in.
> Regarding intended use-case for multiple-keysyms, I consider it mainly
> to be for sequences with combining characters - not everything has
> precomposed codepoints, so if you want one of these, you don't have a
> way to do it with single-keysym, but it still conceptually fits in a
> keymap. However for the original intent you have to ask Daniel.

Yes, it is supposed to be atomic: the usecase was for keymaps (there was
one from central Asia - can't remember off the top of my head), where
Unicode no longer adds precomposed characters, so some key presses need to
generate multiple symbols which should be processed all at once.

> > I'm not saying the patch is wrong, in fact, the layout-search logic is
> > actually what you wrote for kmscon and I appreciate that. I'm just
> > saying that it's a really subtle API difference that can introduce
> > weird bugs. Lets see how it works out, but if people start using
> > xkb_state_key_get_utf32(), I might send a patch adding an xkb-state
> > flag that disables this transformation. Or just force users to not use
> > it (which would be unfortunate).
> A flag makes sense; I try to to add stuff when someone really needs it,
> not preemptively. Btw, xkb_state_new() doesn't take a flags arg - argh.

Yeah, I'm now regretting not adding that flag param! One for 1.0 perhaps ...

> But in general this stuff should be the default, we initially tried to
> avoid these nonsensical US-centric behavior (let's say intentionally :),
> but both the keymaps and existing users actually depend on them, like
> the capitalization and Control thing (and they are also there in the
> spec).

Indeed - there've been quite a few people surprised by this, who were
expecting the Xlib-style behaviour.

> > Btw., same is true for the implicit caps-lock magic in
> > xkb_state_key_get_one_sym(). I'm now quite confused whether
> > xkb_state_key_get_syms() users have to do caps-lock handling
> > explicitly? Or is that done by keymaps?
> Currently to get the implicit capitalization with get_syms(), you have
> to do this:
>     int nsyms;
>     const xkb_keysym_t *syms;
>     xkb_keysym_t sym;
>     nsyms = xkb_state_key_get_syms(..., &syms);
>     if (nsyms == 1) {
>         sym = xkb_state_key_get_one_sym(...);
>         syms = &sym;
>     }
> I imagine the disgust, but given the set of constraints we had I
> couldn't think of any way to make this work. New API is still possible,
> but then we'd have *three* ways to get keysyms...
> As I may have mentioned, I wanted to change the *keymaps* so the
> difference doesn't matter here. I still plan to send some patches for
> easy cases, but fixing other cases would require major xkeyboard-config
> surgery. So we're stuck with it.

It's indeed really unpleasant, and definitely the worst corner of our API
right now.  FWIW, the reason this evolved this way is because
xkb_state_key_get_syms returns a pointer which will remain valid and
pointing to the same symbols for the life of the state object.  Having to
do mapping on the fly obviously blows that out of the water, unless we
allocate an area for composed symbols and retain that; except that it's not
an area, because if you have to grow, it's multiple areas.

Which would be painful and irritating, but I think serves the greater good
of harmonising the API and eliminating one of the very few sources of
genuine surprise.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20140331/b5a5113f/attachment.html>

More information about the wayland-devel mailing list