makekeys: replace helper with python script and binary search

This removes the complicated and undocumented hash-table creation-helper
and replaces it with an autogenerated sorted array. The search uses simple
bsearch() now.

We also tried using gperf but it turned out to generate way to big
hashtables and when reducing the size it isn't really faster than
bsearch() anymore.

There are no users complaining about the speed of keysym lookups and we
have no benchmarks that tell that we are horribly slow. Hence, we can
safely use the simpler approach and drop all that old code.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Add xkb_keysym_from_name() flags argument for case-insensitive search

This adds a flags argument to xkb_keysym_from_name() so we can perform a
case-insensitive search. This should really be supported as many keysyms
have really weird capitalization-rules.

However, as this may produce conflicts, users must be warned to only use
this for fallback paths or error-recovery. This is also the reason why the
internal XKB parsers still use the case-sensitive search.

This also adds some test-cases so the expected results are really
produced. The binary-size does _not_ change with this patch. However,
case-sensitive search may be slightly slower with this patch. But this is
barely measurable.

[ran: use bool instead of int for icase, add a recommendation to the
doc, and test a couple "thorny" cases.]

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
utils: add and use ARRAY_SIZE macro

Signed-off-by: Ran Benita <ran234@gmail.com>
Commit and distribute ks_tables.h

The ks_tables.h file is generated by makekeys.py from
xkbcommon-keysyms.h, which in turn is generated initially by 'make
update-keysyms'. The xkbcommon-keysyms.h file is commited to git and
distributed in the tarball. Since ks_tables.h should only ever change
when xkbcommon-keysyms.h changes, it is more sensible to update them
together and treat them the same, instead of generating ks_tables.h
every time for every builder with 'make', as we do now.

This means we don't need python as a build dependency (only the one
running update-keysyms, i.e. no one, needs this), and we can be
sure exactly the same file is used by everyone. We also don't need to
run makekeys.py on every build.

Signed-off-by: Ran Benita <ran234@gmail.com>
Clean up xkb_sym_interpret a bit

First we split the LEVEL_ONE_ONLY bit off of the 'match' field, which
allows us to turn enum xkb_match_operation to a simple enum and remove
the need for MATCH_OP_MASK.

Next we rename 'act' to 'action', because we've settled on that
everywhere else.

Finally, SIMatchText is changed to not handle illegal values - it
shouldn't get any. This removes one usage of the GetBuffer hack.

Signed-off-by: Ran Benita <ran234@gmail.com>
Contextualize GetBuffer()

Instead storing the buffer in a non-thread-safe static array, we move it
to the context.

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove a couple more uses of static char buffers

Signed-off-by: Ran Benita <ran234@gmail.com>
Move _text() functions from keymap-dump to text.c

And make them use context_get_buffer() instead of using a static char
array.

This was the last non-thread-safe piece we had, as far as I can tell.

Signed-off-by: Ran Benita <ran234@gmail.com>
Silence a couple of warnings

These appear to come and go randomly.

Signed-off-by: Ran Benita <ran234@gmail.com>
doc: add note about X11 vs. extended keycodes

Signed-off-by: Ran Benita <ran234@gmail.com>
Split the mods, layout, leds parts of xkb_state_components

Note first:
This commits breaks the ABI somewhat. If an application is run against
this commit without recompiling against the updated header, these break:
    - xkb_state_layout_*_is_active always retuns false.
    - xkb_state_serialize_mods always returns 0.
So it might break layout switching in some applications. However,
xkbcommon-compat.h provides the necessary fixes, so recompiling should
work (though updating the application is even better).

Split the enum to its individual components, which enables us to refer
to them individually. We will use that later for reporting which
components of the state have changed after update.

Signed-off-by: Ran Benita <ran234@gmail.com>
state: add struct state_components

This holds all of the state component fields in the state in one struct.
We will later want to keep the previous state components after updates,
so this will allow us to do it without duplicating the fields.

Signed-off-by: Ran Benita <ran234@gmail.com>
Report which components of the state have changed

We add a return value to the xkb_state_update_key and
xkb_state_update_mask, which reports to the caller which of the state
components have changed as a result.

This restores the XKB functionality of the XkbStateNotify and
XkbIndicatorsStateNotify events. See:
http://www.x.org/releases/current/doc/kbproto/xkbproto.html#Events
It is quite useful in some situations. For example, it allows an
application to avoid doing some work if nothing of relevance in the
state has changed. Say, a keyboard layout applet. Also useful for
debugging.

The deltas themselves are not provided, because I can't see a use case.
If needed, it should be possible to add some API for that.

In xkbcommon, keymaps are immutable, so all of the other *Notify events
from XKB are irrelevant.

Signed-off-by: Ran Benita <ran234@gmail.com>
test/interactive: add option to show state changes

Pass -c to see.

Signed-off-by: Ran Benita <ran234@gmail.com>
Change update_mask arguments to read 'depressed' instead of 'base'

Just to be consistent, as we use 'depressed' everywhere else in the API.

Signed-off-by: Ran Benita <ran234@gmail.com>
autogen: use --force instead of --symlink

--force copies and installs all the autotools support files, rather than
making symlinks, which can sometimes break things when upgrading your
system autotools.  This is what xserver does.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
state: fix typo in state component copying

Gladly no-one should have been fast enough to hit this.

Signed-off-by: Ran Benita <ran234@gmail.com>
keymap: use plain array for keymap->group_names

Again it is not resized.

Signed-off-by: Ran Benita <ran234@gmail.com>
test/interactive: use num_layouts_for_key()

This is the more appropriate for a specific key (also considering the
num_layouts() is a bit of a made-up value).

Signed-off-by: Ran Benita <ran234@gmail.com>
doc: move include_path functions to a separate group

These are 'special intrest' function, like the logging functions, so
it's nice to have them in their own logical group.

Signed-off-by: Ran Benita <ran234@gmail.com>