Commit Graph

351 Commits (fef179cfe7d8d72a0705202e9dcfd2196932f3ac)

Author SHA1 Message Date
Ran Benita 300f3fb1e0 Don't printf NULL strings
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita 2a026f6f72 test/data/symbols: keypad can only have one default section
Avoids a warning, from xkeyboard-config:

commit 6676053f2c93596c2aaa9905151a5c76355a1540
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Jun 29 09:53:45 2012 +1000

    symbols: keypad can only have one default section

    Warning:          Multiple default components in keypad
                      Using x11, ignoring pointerkeys

    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita f3c4032f35 Set log level for tests through env, not directly
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>
2012-09-03 10:31:12 +03:00
Ran Benita 8d7d9792d1 log: replace "priority" by "level" everywhere
Now that we don't use syslog, "level" does sound more commonplace. We
should change it while there is still nobody using it.
Also leave some space between the integers of the xkb_log_level enum
values, if we ever need to shove more in between.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita 06d7803a6d state: fix mod_names_are_active
This function was always returning -1.
Adding a test, we see that test/state.c treat the is_active functions as
returning booleans, which would treat -1 as success, so we test for > 0
instead (most users would probably get this wrong as well...).
Also update the documentation for the are_active functions, and add a
ATTR_NULL_SENTINEL for gcc __attribute__((sentinel)).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 9de067aad4 compat: ignore "group" (compatibility) statements
Group compatibility statements are like the following:
    group 3 = AltGr;
This currently results in:
    keymap->groups[2].mask = <real mod mapped from AltGr vmod>
And we don't do any thing with this value later. The reason it exists in
XKB is to support non-XKB clients (i.e. XKB support disabled entirely in
the server), which do not know the concept of "group", and use some
modifier to distinguish between the first and second keyboard layouts
(usually with the AltGr key). We don't care about all of that, so we can
forget about it.

One artifact of this removal is that xkb_map_num_groups no longer
works, because it counted through keymap->groups (this wasn't entirely
correct BTW). Instead we add a new num_groups member to the keymap,
which just hold the maximum among the xkb_key's num_groups. This also
means we don't have to compute anything just to get the number of
groups.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-01 10:59:47 +03:00
Ran Benita 16f2de8bf0 compat: ignore "locking" field in sym interprets
This field is used in conjunction with key behaviors, which we don't
support since c1ea23da5. This is also unused in xkeyboard-config.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-01 10:59:46 +03:00
Ran Benita 7ef359def1 rulescomp: remove bad failtests
Since we now handle empty model/layout, the last couple of tests should
not fail. The reason they do is bacause they try to use a non-existent
"base" rules file. When the file is brought in these tests do not fail.
Since we already test for non-existent rules file, we can remove them,
and refine the other tests a bit.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-01 10:58:10 +03:00
Ran Benita cdc228eaf6 Organize xkbcomp/ header files
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>
2012-09-01 10:58:10 +03:00
Ran Benita 3634b1565e Allocate xkb_component_names on stack
Instead of malloc'ing it as well. Also improve the error handling.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-01 10:58:10 +03:00
Ran Benita 5a51ce8b36 Fix warning
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-09 01:55:30 +03:00
Daniel Stone 2f1f1bca5b Add xkb_map_mod_mask_remove_consumed
A fairly simple helper which, given an xkb_mod_mask_t, removes all
modifiers which are consumed during processing of a particular key.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:31 +02:00
Daniel Stone 5e276adb92 Add xkb_log_level enum rather than using syslog
Instead of relying on people including syslog.h, add our own
XKB_LOG_LEVEL_* defines.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:31 +02:00
Daniel Stone ba8458a9fd Increase log verbosity in tests
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:31 +02:00
Daniel Stone 93f6517cd0 stringcomp: Make test more punishing
Recreate the old test/dump scenario, where we test the following map:
  - rules: evdev
  - model: pc104
  - layout #1: us
  - layout #2: ru
  - layout #3: ca(multix)
  - layout #4: de(neo)

This is ever so slightly altered from the xkbcomp output; running the
following:
setxkbmap -rules evdev -model pc105 -layout us,ru,ca,de -variant
,,multix,neo -print | xkbcomp -xkb - -

will give you a map with RCTL added to the modifier_map for both Control
and Mod3.  Running the output through xkbcomp -xkb - - again, will give
you RCTL only added to Mod3.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:31 +02:00
Daniel Stone e756e9b532 test/dump: Remove superfluous test
No longer necessary now we have stringcomp doing a full round-trip test
for us.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:30 +02:00
Daniel Stone fb4d3aefc3 test/stringcomp: Perform full round-trip test
We now pass! \o/

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:30 +02:00
Daniel Stone 6701fb5fe5 stringcomp: Remove unnecessary Level1 mappings
As a map will implicitly go to level one unless explicitly mentioned
otherwise, remove all explicit =Level1 mappings, except for those with
preserve entries.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:30 +02:00
Daniel Stone 6021a9762b test: Minimise includes
Mostly from functions which used to use file functions directly, but now
use test.h wrappers.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:30 +02:00
Daniel Stone 39da9274a7 stringcomp: Update input file for output changes
Bring the input file into line with recent changes to the dump output,
so we're as close as we can get to a round trip.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:30 +02:00
Daniel Stone ce2e4899b5 test: Add extremely rudimentary include path test
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:30 +02:00
Daniel Stone 8fe2a484c0 Rename xkey test to keysym
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:30 +02:00
Daniel Stone 5cf4f51044 Staticise xkb_map_new_from_kccgst
We didn't expose this to the outside world, and its only trivial user
was xkb_map_new_from_rules.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:30 +02:00
Daniel Stone 1eda9e44b1 test: Use test_compile_*() in interactive
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 13:30:24 +02:00
Daniel Stone 04253fb2eb Add support for default rules/model/layout
Right now it just comes from build-time, but eventually this should be
sourced from configuration files at runtime too.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 13:30:24 +02:00
Daniel Stone 055b303493 tests: Fix uninitialised-use-of-'ret' warning
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 13:30:24 +02:00
Daniel Stone 3f0169424f test: Use test_get_context() in interactive
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 13:30:24 +02:00
Ran Benita 1a930bf256 Add API to query whether a modifier is consumed
Currently the user has no way of knowing which of the active modifiers
have been used in the translation of a keycode to its keysyms. The use
case is described in the GTK docs: say there's a menu accelerator
activated by "<Alt>+". Some layouts have "+" shifted, and some have it
on the first level. So in keymaps where "+" is shifted, the Shift
modifier is consumed and must be ignored when the user is testing
for "<Alt>+". Otherwise, we may get "<Alt><Shift>+" and the accelerator
should not actually fire.

For this we also use the preserve[] information in the key types, which
can forces us to report modifiers as unconsumed even if they were used
in the translation. Until now we didn't do anything with this
information.

The API tries to match its surronding. It's not very efficient but this
can be fixed.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-08 10:03:38 +03:00
Ran Benita a681c6240d types: remove DeleteLevel1MapEntries
If there is no map entry for some modifier combination, the default is
to use level 1. The removed code is an optimization to save some space
by removing these entries. But it doesn't actually save any space, and
did not in fact remove all level 1 entries (it walks the array while
modifying it so there's an off-by-one error).

We can instead keep them in the types but just not print them in
keymap-dump.c, to get about the same behavior.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 13:20:37 +03:00
Ran Benita b0b11c4e2e types: don't use canonical/required types
Xkb required every keymap to have at least the four following canonical
types: ONE_LEVEL, TWO_LEVEL, ALPHABETIC, KEYPAD. This is specified in
e.g. the kbproto spec and XkbKeyTypesForCoreSymbols(3) man page.

If these types are not specified in the keymap, the code specifically
checks for them and adds them to the 4 first places in the types array,
such that they exist in every keymap. These are also the types (along
with some non-required 4-level ones) that are automatically assigned to
keys which do not explicitly declare a type (see FindAutomaticType in
symbols.c, this commit doesn't touch these heuristics, whcih are also not
very nice but necessary).

The xkeyboard-config does not rely on the builtin xkbcomp definitions of
these types and does specify them explicitly, in types/basic and
types/numpad, which are virtually always included.

This commit removes the special behavior:
- The code is ugly and makes keytypes.c harder to read.
- The code practically never gets run - everyone who uses
  xkeyboard-config or a keymap based upon it (i.e. everyone) doesn't need
  it. So it doesn't get tested.
- It mixes policy with implementation for not very good reasons, it
  seems mostly for default compatibility with X11 core.
- And of course we don't need to remain compatible with Xkb ABI neither.

Instead, if we read a keymap with no types specified at all, we simply
assign all keys a default one-level type (like ONE_LEVEL), and issue
plenty of warnings to make it clear (with verbosity >= 3). Note that
this default can actually be changed from within the keymap, by writing
something like
    type.modifier = Shift
    type.whatever_field = value
in the top level of the xkb_types section. (This functionality is
completely unused as well today, BTW, but makes some sense).

This change means that if someone writes a keymap from scratch and
doesn't add say ALPHABETIC, then something like <AE11> = { [ q Q ]; }; will
ignore the second level. But as stated above this should never happen.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 13:20:37 +03:00
Ran Benita 9617b092e2 filecomp: fix path and error message
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 1d570a6d46 interactive: add support to run from keymap file
This is useful for quickly testing a random keymap file. Use -k <PATH>.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita cfd978b89d keyseq: use our own keysyms
Instead of <X11/keysym.h>

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 4c21275301 Add an interactive evdev test
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
2012-07-28 11:43:15 +02:00
Daniel Stone ca7927ae60 context test: Use test_get_context()
So we don't die if we haven't got a valid global include path.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-27 11:59:55 +02:00
Ran Benita 89723b7cb7 utils: add/replace string equality macros
It's more tidy and less error prone, since we use strcasecmp == 0 a lot.
We replace strcmp == 0 by streq, strcasecmp == 0 by istreq,
uStrCasePrefix by istreq_prefix and uDupString by strdup_safe.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 00:27:24 +03:00
Ran Benita c6279b8bae expr: don't divide by zero
Calculator parser 101.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-26 23:15:54 +03:00
Ran Benita 3dc1252d2d Add test for logging functionality
Just to make sure everything works properly.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita 81d029f563 Replace xkb_keycode_t 'key' variable name by 'kc'
We want to reserve the name 'key' for something else.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18 12:35:48 +03:00
Daniel Stone 9308a46039 Run source tree through uncrustify
.uncrustify.cfg committed for future reference also, but had to manually
fix up a few things: it really likes justifying struct initialisers.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-17 10:20:15 +01:00
Ran Benita a3378338bd remove unused function xkb_canonicalise_components
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>
2012-07-13 19:07:03 +03:00
Daniel Stone 3640e14d9e Add multiple-keysyms-per-level to test data
Make sure this keeps on working.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-13 00:39:34 +01:00
Daniel Stone a19abd2635 rulescomp: Fix benchmark runs
We'd accidentally inverted silent vs. non-silent compilation, which
would skew the benchmark pretty badly, but also forgot to change base to
evdev for the rules here.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-13 00:32:41 +01:00
Daniel Stone a77e9a92e9 tests: Update dump.data for recent fixes
Makes the test pass again.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-13 00:12:57 +01:00
Ran Benita f059967592 dump: add back kccgst names
Readd the component names to the keymap->names struct. This is used when
printing the component, e.g.

xkb_keymap {
	xkb_keycodes "evdev+aliases(qwerty)" {

instead of

xkb_keymap {
	xkb_keycodes {

This makes diffing against xkbcomp $DISPLAY a bit easier and is kind of
useful anyway.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-13 00:11:29 +01:00
Ran Benita fe5bfdf9d8 dump: a few more tweaks to match xkbcomp output
Only uppercase / lowercase stuff.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-12 18:24:30 +01:00
Ran Benita 9e5052259a symbols: fix bug in modifier_map handling
The code used to match a keysym to a keycode (see added comment)
differed in behavior from xkbcomp, always taking the first key it found.
This caused some incorrect interpretation of the xkeyboard-config data,
for example the one corrected in dump.data (see the diff): since the
de-neo layout sets the both_capslock option, the Left Shift key (LFSH)
has the Caps_Lock keysym in group 4 level 2; now since
    keycode(Left Shift) = 50 < keycode(Caps Lock) = 64
the Left Shift one was picked, instead of the Caps Lock one which is
group 1 level 1. The correct behavior is to pick according to group,
level, keycode.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-12 18:08:00 +01:00
Daniel Stone 62deaeb570 Import dataset into test/data/
Use a self-contained dataset instead of relying on a globally-installed
set.  Data taken from xkeyboard-config 2.5.1.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-12 14:48:49 +01:00
Daniel Stone 3e86ebca06 Add a library of common test functions
Including creating a context (will come in useful soon), opening and
reading files, and compiling keymaps.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-12 14:48:22 +01:00
Daniel Stone 059c1842ef Move test data files to test/data/keymaps
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-12 14:14:50 +01:00
Ran Benita 1f49290131 Enlarge keysym name buffers and mention in comment
The longest keysym is 27 chars long.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-12 09:42:20 +01:00
Ran Benita 010242593e test/dump: output commentary to stderr
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-12 09:42:15 +01:00
Ran Benita 09d1445b4a keyseq: add a failing group-switching test
For some reason, with the grp:alt_shift_toggle option, the following
sequence switches a group:
< Left Shift down, Left Alt down >
While the reverse doesn't:
< Left Alt down, Left Shift down >
And it should.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-12 09:42:10 +01:00
Ran Benita 19f814f95e rules: fix parsing of multiple options
This was broken by commit 18d331b86b
(where only the first option out of a comma-separated string was
matched). Do it correctly this time and add a test.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-12 09:42:08 +01:00
Ran Benita e201c16536 state: fix base mod set/clear behavior
This commit fixes the incorrect current behavior, where at the end of the
following key sequence
Left Shift down, Right Shift down, Left Shift up
the Shift modifier is cleared.

Clearly the code is not as nice as before, but it seems like some count
of the depressed modifiers must be kept.

The code is lifted mostly as is from xkbActions.c. [ There they also
assign to setMods and clearMods each time and not OR it. I assume its
correct, although I wouldn't have guessed... ]

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-01 10:21:01 +03:00
Ran Benita 37f4384947 rules: remove support for keymap rule
This commit removes the ability to specify a keymap *in a rules file*,
e.g. in /usr/share/X11/xkb/rules/evdev or somesuch. This is unused in
xkeyboard-data, and the current code has never even supported it,
because xkb_map_new_from_kccgst (which is no longer exposed in the API)
checks to see that one of the usual components (e.g. symbols, types, ..)
has been filled, while the rules parser, on the other hand,  doesn't
allow to specify a keymap and other stuff at the same time.

( The idea was to remove xkb_map_new_from_kccgst entirely, but it's used
  by a test so it can stay. )

tl;dr: dead code. Of course passing a keymap file to
xkb_map_new_from_file still works.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-01 00:51:56 +03:00
Daniel Stone 6d606d1068 state: Add more comprehensive repeating test
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-22 15:30:17 +01:00
Daniel Stone 8e2c66e9ea Add xkb_key_repeats
Does what it says on the box.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-22 15:27:05 +01:00
Ran Benita 0015604ade Add a test for the results of key sequences
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>
2012-06-18 15:19:24 +01:00
Ran Benita 955ed8c469 state: use darray for filters
For the darray we need to specify the explicit struct xkb_filter type
instead of void*, so we move the definition of struct xkb_state into
state.c thus making it opaque even from the rest of the files. It has
enough getters to get going and is otherwise good style.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 13:21:21 +03:00
Ran Benita d0718e988c test/dump: allow to run manually
Without the srcdir envvar (and a couple trivial changes).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 12:34:57 +03:00
Ran Benita 1c27bb8e77 Update .gitignore
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 12:34:57 +03:00
Daniel Stone 6992de408a Add keypad sequences to UTF-8 keysym printing
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-08 14:59:07 +01:00
Rob Bradford e0524296d2 Add API for getting unicode representation of a keysym
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.]
2012-06-08 14:04:49 +01:00
Daniel Stone 77c909dee2 Fix tiny memory leak in dump test
We forgot to free the path we'd allocated with asprintf.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-04 16:16:20 +01:00
Daniel Stone 0f09c3073c Make xkb_map_get_as_string test more comprehensive
Add a test/dump.data file which contains the result we're expecting from
xkb_map_get_as_string run on a particularly complex set of keymaps, and
assert that the string representations are the same.  This means that
any updates to xkb_map_get_as_string will also need to update the test
data, but should also ensure that we don't have any more parser
regressions.

Compared with diff to the output of setxkbmap + xkbcomp for the same
keymap; seems completely solid.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-04 13:27:41 +01:00
Daniel Stone 64c277d9f2 Revert "dump"
(Ahem.)

This reverts commit f43f75fb83.
2012-06-04 13:08:01 +01:00
Daniel Stone f43f75fb83 dump 2012-06-02 15:29:21 +01:00
Daniel Stone c87468e926 stringcomp: NULL-terminate string
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-29 16:19:24 +01:00
Daniel Stone 243daf80d0 Add test for xkb_map_new_from_string
Using data from xkb_map_get_as_string.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-29 15:08:35 +01:00
Daniel Stone ebd397e184 Add xkb_map_get_as_string
Returns a newly-allocated string representing the specified keymap.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-29 15:07:18 +01:00
Ran Benita 869c687190 rules: add test
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>
2012-05-20 20:31:49 +03:00
Ran Benita beccc37509 Don't run the benchmark by default
For people running 'make check' on every compilation, this can be
a nuisance.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:19 +03:00
Ran Benita b89b8e7023 Change xkb_map_new_from_fd to use FILE*
i.e. xkb_map_new_from_file. The reason is that flex only works with
FILE's, so we must use fdopen on the file descriptor; but to avoid a
memory leak, we must also fclose() it, which, in turn, closes the file
descriptor itself.

Either way is not acceptable, so we can either:
* dup() the fd and use fdopen on that, or
* have the user call fdopen on his own, and accept a FILE* instead of an
  fd.

The second one seems better, and is standard C, so why not. We must add
stdio.h to xkbcommon.h though, which is regrettable, but not a big deal.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-18 20:54:33 +03:00
Daniel Stone 661cb84051 Add benchmarking test to rulescomp
Apparently it only takes us 8ms to build keymaps.  Nice!

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-18 01:04:35 +01:00
Daniel Stone 7b00485a6b Rename 'ctx' back to 'context' in external API
Still keep things as 'ctx' internally so we don't have to worry about
typing it too often, but rename the user-visible API back as it was
kinda ugly.

This partially reverts e7bb1e5f.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-11 15:03:43 +01:00
Daniel Stone 46441b1184 Move KcCGST API to internal-only
And don't export it.  We don't need it for X11 support, let alone
anything else.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09 20:49:04 +01:00
Daniel Stone 2761b1a332 Rename serialise to serialize
Yes, British English is correct, but unfortunately we've lost that
battle.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09 20:49:01 +01:00
Daniel Stone 5a3771d149 Add common LED names to xkbcommon-names.h
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09 20:18:30 +01:00
Daniel Stone 6433d72e7c Merge remote-tracking branch 'krh/keysyms'
Conflicts:
	src/keysym.c
	src/misc.c
	src/text.h
	src/xkbcomp/expr.c
	src/xkbcomp/parser.y
	src/xkbcomp/parseutils.c
	src/xkbcomp/symbols.c

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09 20:15:46 +01:00
Kristian Høgsberg ace1e5df6d Use our own keysyms 2012-05-09 14:21:15 -04:00
Ran Benita e7bb1e5fd9 Shorten context to ctx
(This breaks the API.)

"context" is really annoying to type all the time (and we're going to
type it a lot more :). "ctx" is clear, concise and common in many other
libraries. Use it!

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

[daniels: Fix for xkb -> keymap change.]
2012-05-09 17:52:26 +01:00
Daniel Stone 38cb639082 Change all 'xkb' xkb_keymap names to 'keymap'
To make it a bit more clear what it actually is.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09 15:17:25 +01:00
Daniel Stone e1af48bc04 Rename keysym <-> string API
Change them to refer to the string representation of the keysym's name
as a name rather than a string, since we want to add API to get the
Unicode printable representation as well.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09 13:22:34 +01:00
Daniel Stone 124e62e48f Add multiple modifier state matching API
Two new calls allow users to test the exact modifier state, including
verifying that no other modifiers but the ones you wanted are down.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09 01:06:10 +01:00
Daniel Stone 74a197d271 Add pre-defined names database
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>
2012-05-08 17:59:35 +01:00
Daniel Stone c358428009 Add flags to context creation
None defined as yet, but why not.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08 17:51:16 +01:00
Daniel Stone b537b5524a Add flags to keymap compilation entrypoints
No use as yet, but might as well ...

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08 17:48:29 +01:00
Ran Benita b610b2b953 Rename XKBcommonint.h to xkb-priv.h and use it
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>
2012-05-08 17:29:43 +01:00
Ran Benita fbfbf0aa4b Remove left over filecomp.sh file
Should have removed it in a previous commit.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-08 17:28:53 +01:00
Ran Benita 40b56b0fe3 Update .gitignore for automake 1.12
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-08 17:28:52 +01:00
Ran Benita a1e07fb6f6 Uncomment sections of test/rulescomp.c
Fixes an 'unused' warning. There seems to be nothing wrong with these
sections though, all the tests pass.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-08 17:28:50 +01:00
Ran Benita 12b3495ddf Remove unused 'which' and 'merge' arguments
Signed-off-by: Ran Benita <ran234@gmail.com>

[daniels: Updated for xkb_desc -> xkb_keymap changes.]
2012-05-01 13:57:31 +01:00
Ran Benita 4b49e0a117 Overhaul test suite
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.]
2012-04-09 14:21:47 +01:00
Daniel Stone ef88c7efab Rename xkb_desc to xkb_keymap
struct xkb_desc was just a hangover from the old XkbDescRec, which isn't
a very descriptive name.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-04-09 13:47:23 +01:00
Daniel Stone 9b14e0c311 Tests: Release context on failure to build keymap
No practical effect since they exit(1) regardless, but it keeps valgrind
happy.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-29 17:38:44 +01:00
Daniel Stone 034ffce664 Use xkb_contexts in keymap compilation
Primarily for the include path, but also for the logging in future.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27 17:22:35 +01:00
Daniel Stone 3e9dd7512c Add new context API
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27 16:59:01 +01:00
Daniel Stone 21f1bff4af Fix distcheck with non-recursive Makefiles
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27 15:56:06 +01:00
Ran Benita b5efe41f19 Make build non-recursive
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>
2012-03-27 14:17:34 +01:00
Ran Benita 602e87805b Define our own NoSymbol value and use it
Since we have our own xkb_keysym_t type, it makes sense to have our own
NoSymbol value instead of the one from X11/X.h.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:16:36 +01:00
Ran Benita d3908b631c Define our own None atom value
Since we define our own xkb_atom_t type, it makes sense not to use the
X11/X.h None value. This way we can also remove a lot of X11 includes.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:16:11 +01:00
Ran Benita 0480f427ad Remove useless stuff from utils
Signed-off-by: Ran Benita <ran234@gmail.com>

[daniels: fixed conflicts from strcasecmp, added includes to make
          filecomp build again]
2012-03-27 14:09:27 +01:00
Ran Benita d22b8dbbd0 Move utils.{c,h} to be used by the entire project
This is a first step for making consistent use of utils.h also outside
of xkbcomp/ .

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 13:59:51 +01:00
Ran Benita f52671a4d1 Remove a few remaining uses of the KeySym type
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 13:59:22 +01:00
Ran Benita 8b3e2b9b00 Add xkb test file to EXTRA_DIST
To appease make distcheck.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 13:59:19 +01:00
Ran Benita eeb0a21448 Update gitignore for 'state' test
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 13:59:15 +01:00
Daniel Stone ede8473490 Add enum xkb_key_direction instead of bool
Use XKB_KEY_UP instead of 0 and XKB_KEY_DOWN instead of 1.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reported-by: Ran Benita <ran234@gmail.com>
2012-03-27 12:18:41 +01:00
Daniel Stone 7f471a702e Add state serialisation API
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27 12:11:27 +01:00
Daniel Stone d039622a65 Rename keymap allocation API
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-22 17:39:12 +00:00
Daniel Stone 3d672fcfea Add LED state API
And also convert state.c to use the state API for mods and groups,
rather than testing the state members directly.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-22 14:32:53 +00:00
Daniel Stone edcaab6512 Round out new state API
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-21 15:25:45 +00:00
Daniel Stone ecea0d71b2 Add new state API
Add new API to deal with xkb_state objects, including
xkb_state_update_key, which runs the XKB action machinery internally to
calculate what exactly happens to the state when a given key is pressed
or released.

The canonical way to deal with keys is now:
    struct xkb_state *state = xkb_state_new(xkb);
    xkb_keysym_t *syms;
    int num_syms;

    xkb_state_update_key(state, key, is_down);
    num_syms = xkb_key_get_syms(state, key, &syms);

More state handling API, including a way to get at or ignore preserved
modifiers, is on its way.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-21 02:22:04 +00:00
Daniel Stone 7e2dd12142 Add geometry test
Add the dump of my full current X11/XKB keymap as a test for filecomp,
being as it also includes geometry.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-15 09:44:55 +00:00
Daniel Stone b8e950defd filecomp: Fix xkbcomp warning
Ironically, the test for named.xkb included a call that relied on the
default keymap, without the file naming an explicit default.  Go figure.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-09 19:30:31 +00:00
Daniel Stone ed5c6c1796 Remove geometry support, again
It still parses geometry, but happily throws it away.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-09 19:30:30 +00:00
Ran Benita 0d8874d01c makekeys: update to match the rest of libX11 makekeys
This integrates two commits from libX11:

ebd6ef0a4db0ddef0ae17ad14571518ccdeea5ba
   XStringToKeysym: Special case for XF86 keysyms

    Some XFree86 keysyms were in XKeysymDB as XF86_foo, despite really being
    XF86foo.  So, if we get to the bottom of XStringToKeysym and haven't
    found our XF86_foo, try it again as XF86foo.

    Signed-off-by: Daniel Stone <daniel@fooishbar.org>
    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>

00175397480b76d32bf82b0c7c94c91a2a95954e
    makekeys: Scan vendor keysyms as well as core

    Since we can't really live without vendor keysyms, scan them all in to
    generate ks_tables.h, rather than only doing the core ones, and leaving
    the vendor syms to be manually synchronised with XKeysymDB.

    Signed-off-by: Daniel Stone <daniel@fooishbar.org>
    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>

Notice that the xkey.sh test is changed to match libX11 behavior, i.e.
XKeysymToString(0x1008FE20) -> "XF86Ungrab" as opposed to "XF86_Ungrab".

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-02-26 21:09:37 +02:00
Daniel Stone 3077e97e7c tests: Free returned XKB map
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-02-15 16:38:17 +00:00
Daniel Stone 4e22851141 Introduce xkb_keycode_t for keycodes
And use it consistently everywhere, including with a special long-safe
internal keycode type, to ease the transition to large keycodes.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-02-15 16:24:50 +00:00
Daniel Stone ead9d0cb62 Move include path from X11/extensions/ to xkbcommon/
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-02-15 16:24:50 +00:00
Gaetan Nadon 5e43e7b46c config: distribute the .sh test programs and test data
The test programs and the test data are required in the tarball
and needed for distcheck.

Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-12-18 11:19:57 -05:00
Gaetan Nadon f424bd8f5f config: make it easier to add TEST programs
LDADD is a Makefile wide variable.
Automake matches prog name with .c file by default

Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-12-18 11:19:57 -05:00
Gaetan Nadon 63e2719a8f config: replace deprecated INCLUDES with AM_CPPFLAGS
Fixes automake warning.

Acked-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-12-08 15:24:21 -05:00
Gaetan Nadon ceba14dc3e config: update subdirs .gitignore
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-12-07 10:23:18 -05:00
Kristian Høgsberg a84c08795e Use flex for generating the scanner, add support for parsing from strings
Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2010-10-20 14:03:53 -04:00
Kristian Høgsberg e879828717 Don't return a static buffer in public API 2010-10-08 15:33:18 -04:00
Kristian Høgsberg 97fbc348b0 Rename XkbRMLVOSet to struct xkb_rule_names 2010-07-02 14:21:52 -04:00
Kristian Høgsberg 3f0034a990 Rename public entry points to lowercase and underscore 2010-07-02 12:20:59 -04:00
Kristian Høgsberg 5669e1a82d Compile with -fvisibility=hidden when possible 2010-07-02 12:20:59 -04:00
Kristian Høgsberg 9f6026867a Pull in enough structs and defines from XKBstr.h to only need XKB.h
We want to move away from sharing implementation structs and let libX11
and libxkbcommon use each their own set of structs.
2010-07-02 12:20:54 -04:00
Kristian Høgsberg d95b289367 Make XkbcInitAtoms() call optional 2010-06-30 17:13:21 -04:00
Daniel Stone 2c4a045aca Allow external atom databases
Allow people to plug in an external atom database (e.g. the X server's),
so we don't have to migrate our own atoms over later.  We are a bit
over-keen on atoms at the moment, so it does pollute the atom database a
bit though.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:57:16 +01:00
Daniel Stone 5140250273 Add testcase for XkbcCanonicaliseComponents
Should be reasonably thorough; the shell part is, however, quite
unpleasant.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone a8bb86a48a Test: Keysym: Add tests for new keysym <-> string conversions
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone 8e3239a78f KeySym: Actually handle NoSymbol
Add NoSymbol into the keysym table, so keysym <-> string conversion works for
that, too; also eliminate special-casing of VoidSymbol.

This will require special-casing in libX11 to preserve its API.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-04-25 14:56:57 +10:00
Daniel Stone a5ce9754dc test: Fix srcdir != objdir build and test failures
filecomp would fail because it couldn't find the input files, after
compilation failed due to missing includes.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-04-25 14:56:47 +10:00
Dan Nicholson c728d91bde Program and files for testing CompileKeymapFromFile
A few simple test cases for verifying the operation of parsing a keymap
file and compiling a keyboard description from it.
2009-04-10 12:33:31 -07:00
Dan Nicholson e98eb80509 test: Remove extraneous includes
These programs don't actually use the internal API.
2009-04-09 20:52:26 -07:00
Dan Nicholson babae38935 Change CompileKeymapFromRules to take XkbRMLVOSet
Let's use a nice interface now that it's available from XKBrulescommon.h.
2009-04-08 17:54:55 -07:00
Dan Nicholson 6a84a34d86 Remove all non-public API from XKBcommon.h header
The noble intention was to expose all the new API and new generic types
in the split out kbproto headers through XKBcommon.h. It turns out that
would be a massive amount of work in the server. Someday, but first just
wedging in XkbCompileKeymap* would be good.

Most of the API is in new internal xkb*.h headers. In order to allow the
XKBcommon.h header to be used from the server, we can't pull in other
headers from kbproto since the server has its own copies. However, types
that are different (XkbDescRec, XkbAction) still have Xkbc equivalents
here, and I think they should be used in the server.
2009-04-08 07:46:25 -07:00
Dan Nicholson 713c8f418f test: Exercise compiling from components
This could probably use a lot more real world test cases, but it does
the job for now.
2009-04-04 12:54:44 -07:00
Dan Nicholson 4f736db995 test: Minor refactor to allow $EXEEXT in program names 2009-04-04 11:04:35 -07:00
Dan Nicholson 8f9a612990 test: Add logging and some intentionally failing cases
We want to log the output of the tests rather than letting them go to
stderr. This allows tests we expect to fail to be run.
2009-04-04 11:01:58 -07:00
Dan Nicholson 95dbbb8a7b rulescomp: Remove unneeded API 2009-04-04 09:37:53 -07:00
Dan Nicholson 5cc55d7cbb Test compiler to simulate xkbcomp usage
Added a test program, rulescomp, which takes a RMLVO set and generates a
XkbcDescPtr. This is essentially what the xserver will do, except that we
still need to access some xkbcomp internal API to make it work.
2009-04-04 09:14:20 -07:00
Dan Nicholson 1ff77ecd36 Rename headers to XKBcommon* and install in extensions directory
Following the kbproto convention, the headers will be named XKBcommon.h
and XKBcommonint.h. Furthermore, they'll be installed in X11/extensions
directory with the rest of the XKB headers.
2009-03-25 19:40:57 -07:00
Dan Nicholson ffa0ccfad9 Use XORG_CWARNFLAGS for more warnings 2009-03-19 16:25:34 -07:00
Dan Nicholson ba0b312ac8 test: Add tests for XFree86 special keys
Since the XFree86 special keysyms contain an underscore after the XF86
prefix, check to make sure they're handled correctly.
2009-03-19 11:51:10 -07:00
Dan Nicholson 176b9cf524 test: Consistently use upper case hex 2009-03-19 11:51:10 -07:00
Dan Nicholson 49a06f926d test: Add convenience functions for xkey.sh 2009-03-19 11:51:10 -07:00
Dan Nicholson b2737e9bfb Testing harness for keysym functions
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.
2009-03-19 11:51:09 -07:00