This runs a bunch of random keys against xkb_state_update_key() and
xkb_state_key_get_one_sym(), in a fairly unintelligent way.
It might be nice to check when modifying this code path, or changing it,
to see things haven't slowed down considerably. However, given the
numbers this benchmark gives, it is pretty clear that we are not going
to be the bottleneck for anything. So this can more-or-less be ignored.
Incidentally, this also turned out to be a poor man's fuzzer, because it
turned up the fix in the previous commit. Maybe we should consider
beefing it up with an actual 'break stuff' intention and running it as
part of 'make check'.
Signed-off-by: Ran Benita <ran234@gmail.com>
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>
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>
Simple HTML docs generated from the doxygen comments.
After running 'make' or 'make doc', try firefox doc/html/index.html to
see it (if you have doxygen). It's also installed with 'make install'.
You can use --enable-docs or --disable-docs, or specifically
--with-doxygen or --without-doxygen (autodetected, default yes).
The docs are currently not distributed in the tarball, because I
couldn't make it work properly in all cases :/
Signed-off-by: Ran Benita <ran234@gmail.com>
This just prints the compiled keymap string for to the given command
line arguments. This often useful when developing.
Signed-off-by: Ran Benita <ran234@gmail.com>
- Add context.h and move context-related functions from xkb-priv.h to
it.
- Move xkb_context definition back to context.c.
- Add keysym.h and move keysym upper/lower/keypad from xkb-priv.h to it.
- Rename xkb-priv.h to map.h since it only contains keymap-related
definitions and declarations now.
- Remove unnecessary includes and some and some other small cleanups.
Signed-off-by: Ran Benita <ran234@gmail.com>
As there is currently no stable release of xkbcommon, other projects might
want to include a copy of the keysyms so they can be used even though
libxkbcommon may not be available on the machine. However, if xkbcommon.h
is still included, conflicts will occur. Hence, to avoid nasty hacks,
simply include a header protection in xkbcommon upstream.
[daniels: Added protection to Makefile.am's update-keysyms, as well as
XKB_KEY_NoSymbol, and a comment noting that it shouldn't be
updated directly.]
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This way the test logs have all the information, but we don't get eye
bleed every time we run them manually. One can always use
TESTS_ENVIRONMENT (we correctly use AM_TESTS_ENVIRONMENT now), or set
the envvars from the shell.
Signed-off-by: Ran Benita <ran234@gmail.com>
Add CompileKeymap to do most of what compile_keymap_file does now, and
move UpdateKeymapFromModifiers along with it from (mostly unrelated)
compat.c.
Also rename UpdateKeymapFromModifiers to UpdateDerivedKeymapFields,
because it does more than update the modifiers.
Signed-off-by: Ran Benita <ran234@gmail.com>
Various non-functional changes:
- Re-add keycodes.h and move some stuff there.
- Add parser-priv.h for internal bison/flex stuff.
- Don't include headers from other headers, such that file dependencies
are immediate in each file.
- Rename xkbcomp.h -> ast.h, parseutils.{c,h} -> ast-build.{c,h}
- Rename path.{c,h} -> include.{c,h}
- Rename keytypes.c -> types.c
- Make the naming of XkbFile-related functions more consistent.
- Move xkb_map_{new,ref,unref} to map.c.
- Remove most extern keyword from function declarations, it's just
noise (XKB_EXPORT is what's important here).
- Append XKBCOMP_ to include guards.
- Shuffle some code around to make all of this work.
Splitting this would be a headache..
Signed-off-by: Ran Benita <ran234@gmail.com>
The KeyName functions are more appropriate in keycodes.c.
The ProcessIncludeFile can go to path.c along with the other functions
dealing with includes.
Signed-off-by: Ran Benita <ran234@gmail.com>
The program reads key events from evdev input devices, puts them through
the library and prints some information about them. It's nice for
experimenting, quick testing and trying to break it with random stuff
(already found some!).
It is called "interactive" for lack of a better name. It's a bit
hackish, but can easily be extended, made more portable etc, in the
future.
Signed-off-by: Ran Benita <ran234@gmail.com>
Conflicts:
Makefile.am
test/.gitignore
Add new public API to provide the library users with some options to
control and customize the logging output from the library. It is based
upon the skeleton from the libabc demo libray:
https://git.kernel.org/?p=linux/kernel/git/kay/libabc.git
which is public domain and works pretty well.
This requires passing in the context object in every logging call, and
thus the conversion is done file by file. We also remove the global
warningLevel variable in favor of a verbosity level in the context,
which can be set by the user and is silent by default.
One issue is the ACTION calls, which, while nice, do not play very well
with line- and priority-based logging, and would require some
line continuation handling or keeping state or some other compromise. So
instead remove these and just inline them with their respective
warning/error. So instead of:
ERROR("Memory allocation failed\n")
ACTION("Removing all files on hardisk\n")
its something like that:
log_err("Memory allocation failed; Removing all files on harddisk\n")
Signed-off-by: Ran Benita <ran234@gmail.com>
The include/ dir is somewhat redundant and makes it just a bit harder to
handle the -I directives from out side of automake; without it the
default $(top_buildir) just works.
Here's also some further justifications I found:
http://smcv.pseudorandom.co.uk/2008/09/pc-uninstalled/
Signed-off-by: Ran Benita <ran234@gmail.com>
Taken from xserver/include/list.h. The changes made are:
* Drop the xorg_ prefix and some typedef from the end.
* Rename _for_each_entry macros to just _foreach (like darray).
* Rename list_is_empty to list_empty (like darray).
* Add a list_replace function which we use later.
Signed-off-by: Ran Benita <ran234@gmail.com>
The ComputeEffectiveMap function is only called from keytypes.c, with
the last argument NULL, so we can move it there and remove some code.
The function XkbcVirtualModsToRealMods, of which the above is the only
user, is already implemented more simply in compat.c, so make this one
non-static and use it. This leaves src/xkb.c empty, so remove it.
Signed-off-by: Ran Benita <ran234@gmail.com>
commit 46441b1184 removed this from the
public API, and we don't need it internally. So send it to the archives.
Signed-off-by: Ran Benita <ran234@gmail.com>
Including creating a context (will come in useful soon), opening and
reading files, and compiling keymaps.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This test verifies the core purpose of this library, which is to
translate the user's keypresses into keysyms according to the keymap and
the XKB specification.
The tests emulate a series of key presses, and checks that the resulting
keysyms are what we expect.
Several of the tests currently fail, and plenty more should be added and
maybe split up.
It also currently uses an RMLVO keymap, which comes from the
xkeyboard-config data set, and whose behaviour may change in the future.
So it should probably be changed to use several files of our own, but
it's OK for now.
Signed-off-by: Ran Benita <ran234@gmail.com>
Since every user building the library, even from git, doesn't need these
files anymore, there's no need to check for them (this goes for makekeys
as well).
The only remaining user is the update-keysyms target, but whoever will
run it again (if ever) will probably know what he's doing (at least
enough to run git diff before git commit). And the defaults should be
fine too.
Signed-off-by: Ran Benita <ran234@gmail.com>
This code uses a table and code derived from
http://www.cl.cam.ac.uk/~mgk25/ucs/keysym2ucs.c
The added API calls are:
xkb_keysym_to_utf32
xkb_keysym_to_utf8
[daniels: Changed API to be more in line with keysym_get_name, added
test, changed formatting to 4-space.]
bison/flex-generated objects, when being run in a VPATH build with
--disable-dependency-tracking (i.e. Gentoo), would fail to be created
because automake didn't bother creating the destination directories
before trying to create the objects.
Fix this by depending on the destination directory stamp, which
according to the automake mailing list, should hopefully remain fairly
stable.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Add a non-extensive test to check that some basic things (e.g. rule
matching, var substitution, indexes and groups) work as expected.
Signed-off-by: Ran Benita <ran234@gmail.com>
Really all we need from this file is a way to get xkb_component_names
from an xkb_rule_names, which is now the only thing being exposed. This
should allow for some much needed refactoring of this code.
Since this is only used by xkbcomp.c and uses xkbcomp functions, also
move rules.{c,h} under the xkbcomp dir.
Signed-off-by: Ran Benita <ran234@gmail.com>
makekeys must be built with the build-native compiler, not with $(CC)
which is the cross-compiler. The only sane way to achieve this seems to
be to use a separate Makefile.am for it.
This patch fixes the problem apparently caused by:
commit b5efe41f19
Author: Ran Benita <ran234@gmail.com>
Date: Sat Mar 24 04:48:31 2012 +0200
Make build non-recursive
There is no such thing as makekeys_makekeys_CC in automake.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
We depend on parser.h which is generated by flex during the build, so
use an explicit $(top_builddir) rather than a relative path.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
xkbcommon-names.h right now just contains a set of hardcoded modifier
strings that are most commonly used for the usual modifiers. Provide
definitions of these so people don't have to worry about typoing a
string or mixing up Mod1 and Mod4.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Make the files in the src/* directory use their own header or a
consilidated private header. This makes the file dependencies clearer.
Also drop the pointless "xkb" file name prefix, add split a few
declarations to their own files (atom.h and text.h).
Signed-off-by: Ran Benita <ran234@gmail.com>
The include dependencies were quite convoluted, where you change the
order and get a ton of errors. Instead, change one file to act as the
internal interface for the xkbcomp files, and make every file use it.
Also drop the pointless "xkb" prefix to file names.
Signed-off-by: Ran Benita <ran234@gmail.com>
The two files do exactly the same sort of things, without any discernible
reason for splitting them.
Signed-off-by: Ran Benita <ran234@gmail.com>
[daniels: Updated for xkb_desc -> xkb_keymap changes.]
Rewrite all of the current tests in the following ways:
- Instead of the current mix of C and shell, just use single-process
pure C file per test. All of the .sh files are removed, but everything
that was tested is ported.
- Instead of handling the test logs ourselves, use Automake's
"parallel-test" mechanism. This will create a single log file for each
test with it's stdout+stderr, and a top level "test-suite.log" file
for all the failed tests.
- The "parallel-tests" directive also makes the test run in parallel,
so "make check" runs faster.
- Also use the "color-tests" directive to have the "make check" output
colorized. Who doesn't like to see PASS in green?
- All of the test data files are moved into the test/data subdirectory.
That way we can just put the directory in EXTRA_DIST and forget about
it.
- The test/Makefile.am file is consolidated into the main Makefile.am,
for a completely non-recursive build.
Right now the tests are completely independent and just use simple
assert()'s. More sophistication can be added as needed.
It should also be noted that it's still possible to use shell, python,
etc. if a test wants more flexibility than C can provide, just do as
before.
Signed-off-by: Ran Benita <ran234@gmail.com>
[daniels: Updated for xkb_keymap changes.]
The definitions in config.h should be available in all files an
implementation detail; it can be included through the build system
instead of having each file pull it every time.
This is especially helpful with AC_USE_SYSTEM_EXTENSIONS, as _GNU_SOURCE
and friends can have an effect by merely being defined, which can lead
to some confusion if its effective for only half the files.
And we don't really support a build _without_ config.h; so, one less
thing to worry about.
Signed-off-by: Ran Benita <ran234@gmail.com>
Unify all the different Makefile.am into a single short top level one
(the test/Makefile.am file is left intact though).
This makes the build system simpler to look and should encourage
unifying more currently-disparate code.
Some further motivation can be found in this page:
http://www.flameeyes.eu/autotools-mythbuster/automake/nonrecursive.html
Signed-off-by: Ran Benita <ran234@gmail.com>
This program is a utility to generated a header file.
The header file it generates should not be located in the
directory where this utility program is compiled.
Move the /makekeys dir as a sibling of /src.
This reduces the number of bi-directional relationships
between directories.
Make corresponding makefiles simplifications.
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
The -Im4 in Makefile.am will have to wait until the day
there is an m4 macro checked-in git in the m4 directory.
This does not prevent libtool to install its macros in m4.
Acked-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
libtoolize: Consider adding "AC_CONFIG_MACRO_DIR([m4])" to configure.ac and
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
libtoolize: Consider adding "-I m4" to ACLOCAL_AMFLAGS in Makefile.am.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
A test program and script have been added for checking the XkbCommon
keysym functions. This has already highlighted an error in handling of
keysyms from XF86keysym.h.
Add the xkbcommon implementations of XKeysymToString and XStringToKeysym.
These symbols have the namespace prefix of Xkbc and are declared in
X11/XkbCommon.h.
The implementation is taken directly from Xlib, but does not include the
XKeysymDB parsing and hashing yet (if it ever will). A couple type
conversions were needed to keep from using Xlib.h. See original files:
libX11/src/KeysymStr.c
libX11/src/StrKeysym.c
The makekeys utility is used to generate the keysym hash tables during
the build. We try to detect a build machine native compiler so the
tables can be generated when cross compiling.