Commit Graph

175 Commits (471ebad62311e6a36936bed7e04aa634d385d661)

Author SHA1 Message Date
Ran Benita 22684cd1dd parser: remove XkbCompMapList rule
This rule allows you to put several xkb_keymaps in one file.
This doesn't make any sense: only the default/first can ever be used,
yet the others are fully parsed as well.
Different keymaps should just be put in different files.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 14:20:16 +02:00
Ran Benita 693a1f57d1 test/interactive: allow -k to get any absolute path
Instead of looking for a keymap in test/data.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 14:20:16 +02:00
Ran Benita 26cc2f400a Don't use %z printf format
Some libc's don't support it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 14:20:16 +02:00
Ran Benita 92e07726b2 test: add keycodes files which map directly to evdev codes
This is a proof-of-concept for the long key names. The keycodes in the
file evdev-xkbcommon are autogenerated from linux/input.h, and uses the
names given there; all of the previous names are aliased to the new
names, so they continue to work with the symbols files, etc.

You can try it with 'sudo ./test/interactive -r evdev-xkbcommon -n 0'
The -n 0 means that we don't offset the evdev scan codes - just feed
them directly. The -r evdev-xkbcommon just means to use a new rules file
which makes us use the new keycodes file. (The only problem I can see is
with the MENU and LSGT names which has some conflicts).

Maybe some day xkeyboard-config could ship something similar, so that
the 8 offset is unneeded.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27 21:41:54 +02:00
Ran Benita 32c19f4b44 keymap-dump: make it look better with long key names
Not worth messing around with too much, just make it legible.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27 21:31:33 +02:00
Ran Benita 984ebf9838 test/interactive: allow to set evdev offset
If we want to test a keymap without the usual 8 offset.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27 21:12:08 +02:00
Daniel Stone 5aaf65b74e Add xkb_state_key_get_one_sym
The trivial wrapper around xkb_state_key_get_syms that every user to
date has implemented.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-27 23:27:49 +10:00
Ran Benita 9a18b87251 Add format argument to xkb_keymap_get_as_string
This function really needs a format argument, for symmetry with the
keymap creation functions. If we add new formats, we will almost
certainly want to add support for serializing it into a string. It would
also allow to convert from one format to another, etc.

The in the common case, the user would just want to use the format she
used to create the keymap; for that we add a special
XKB_KEYMAP_USE_ORIGINAL_FORMAT value, which will do that (it is defined
to -1 outside of the enum because I have a feeling we might want to use
0 for something else). To support this we need to keep the format inside
the keymap. While we're at it we also initialize keymap flags properly.

This changes the API, but the old xkb_map_get_as_string name works as
expected so this is the best time to do this.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:13:32 +10:00
Ran Benita 0dd40125c5 API: add _context prefix to log-related functions
This is to follow the general scheme set by all of the other API
functions.
Since no one is using these functions yet, we don't (actually better
not) add the old names to xkbcommon-compat.h.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:54 +10:00
Ran Benita 67b03cea0b state: correctly wrap state->locked_group and ->group
These values weren't wrapped before, which caused group_index_is_active
to stop working after a few group switches.

Also, the current group-wrapping function didn't take into consideration
actions such as LockGroup=-1, which need to wrap around, etc.
xkb_layout_index_t is unsigned, but it was used to hold possibly
negative values (e.g. locked_group is 0 and gets a -1 action).

This group wrapping function should now act like the XkbAdjustGroup
function from xserver, and at least ./test/interactive doesn't bring up
any problems with group switching any more.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita c174173209 Don't choke on RMLVO layout string with holes
This old rules parser gives the same kccgst here, so in the interest of
staying compatible we shouldn't fix it there. Similarly we shouldn't
touch ParseIncludeMap, so this is the best place to handle this.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita fcd202909b Don't use xkbcommon-compat names in internal code
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita 2c96828f75 test: add print-compiled-keymap tool
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>
2012-09-19 16:56:26 +03:00
Ran Benita ac872bdfc2 symbols: fix buffer overflow with illegal explicit group
Trying ''./test/interactive -l us:5' causes us to crash.

The <layout>:<N> syntax says to put this layout at the N'th level.
However the code (inherited from xkbcomp) doesn't check that the group
is valid, and then happily indexes keyi->groups with it, which has a
static size of XKB_NUM_GROUPS (the SetExplicitGroup function assumes the
index is valid). So any value a user might put there > 4 makes nice
things happen.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-17 14:30:16 +03:00
Ran Benita dbd7a95359 keyseq: add test for repeat-shift-repeat-unshift-repeat
e.g. hhhhhHHHHHHHhhhhhh with shift down and up in the middle.
Unfortunately trying a quick test with test/interactive is not possible
because the evdev soft-repeat stops the repeat when another key is
pressed. So you need real soft-repeat for that.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-16 15:59:31 +03:00
Ran Benita b21107056e Organize src/ and test/ headers
- 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>
2012-09-16 15:20:18 +03:00
Ran Benita 4b69d6f71d keycodes: ignore explicit minimum/maximum statements
These statements are pretty pointless for us; we don't restrict keycodes
like X does, and if someone writes e.g. maximum = 255 but only has 100
keys, we currently happily alloc all those empty keys. xkbcomp already
handles the case when these statements aren't given, and uses a computed
min/max instead. We should just always use that.
(Of course since keycodes/evdev currently uses almost all of the
keycodes in the range it declares, including 255, this doesn't save any
memory for the common user right now).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-15 02:09:34 +03:00
Ran Benita 8862fd8082 keyseq: test that de(neo) is working properly
This layout stretches us pretty well, so it's good for testing nothing
breaks. There are a couple of things that need looking into, though
(particularly the level5 issue).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 00:07:55 +03:00
Ran Benita 3abfe83e11 symbols: fix real/alias key merge ordering bug
Background:

The CopySymbolsDef has a comment on a couple of lines which supposedly
fixed a bug:

    /*
     * kt_index[i] may have been set by a previous run (if we have two
     * layouts specified). Let's not overwrite it with the ONE_LEVEL
     * default group if we dont even have keys for this group anyway.
     *
     * FIXME: There should be a better fix for this.
     */
    if (!darray_empty(groupi->levels))
        key->kt_index[i] = types[i];

But neither the comment nor the fix make any sense, because the kt_index
is indexed per group, i.e. each group gets its own type.
The original xkbcomp commit which added this (36fecff58) points to this
bug: https://bugzilla.redhat.com/show_bug.cgi?id=436626
which complains about -layout "ru,us" -variant "phonetic," not working
properly. And indeed when we try:
    sudo ./test/interactive -l ru,us -v
the first group doesn't get any syms for the main keys.

The problem (Clearly the fix above is useless):

The ru(phonetic) map is specified using aliases, e.g. LatQ, LatW instead
of AD01, AD02, etc. When combined with another layout which uses the
real names (AD01, AD02), the symbols code should recognize they are the
same key and merge them into one KeyInfo. The current code does that,
but it doesn't catch the case where the alias was processes *before* the
real one; so we get two KeyInfo's and the later one wins. So e.g. the
ru(phonetic) symbols are ignored.

The fix:

Before adding a new KeyInfo to the keys array, always replace its name
by the real name, which avoids the entire issue. Luckily this is done
pretty late so most error messages should still show the alias name.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-13 21:09:46 +03:00
Ran Benita a9fa37396f keymap-dump: don't write spaces between multiple-syms-per-level
This can get a bit unwieldy.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-13 15:57:10 +03:00
Daniel Stone b4b40d73ad Copyright updates
With Dan Nicholson's permission (via email), update his copyright and
license statements to the standard X.Org boilerplate MIT license, as
both myself and Ran have been using.

Clean up my copyright declarations (in some cases to correct ownership),
and add copyright/license statements from myself and/or Ran where
appropriate.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-12 16:58:54 +01:00
Ran Benita 1aa6e2b1e2 test/rules-file: add benchmark
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:13 +03:00
Ran Benita 480f919d77 test: add rmlvo-to-kccgst tool
For a quick look at what components result from the rules.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:13 +03:00
Ran Benita 7f04ffc4d3 rules: fix check for appending '|' character when applying
There are two ways to separate multiple files in XKB include statements:
'+' will cause the later file to override the first in case of conflict,
while '|' will cause it augment it (this is done by xkbcomp). '!' is
unrelated here.
Since '|' is practically never used, this wasn't noticed.

In the modified test, the '|some_compat' previously was just ignored.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
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