Commit Graph

673 Commits (7dc51ea84a5324c54d271fd51d42ad2940acaa76)

Author SHA1 Message Date
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 cd5a827402 utils: remove unused recalloc and related macros
Their use is superseded by darray everywhere now.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 13:21:21 +03: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 a1f8440d70 symbols: use darray in struct xkb_sym_map
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 13:21:21 +03:00
Ran Benita 54bdfd05a4 symbols: use darray for KeyInfo acts
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 13:21:21 +03:00
Ran Benita ce9c18a76e symbols: use darray for KeyInfo symsMapNumEntries
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 13:21:21 +03:00
Ran Benita 920cc27041 symbols: use darray for KeyInfo symsMapIndex
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 13:21:21 +03:00
Ran Benita e82b9b143c symbols: remove sizeSyms array from KeyInfo
This information is kept inside the darray now.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 13:21:21 +03:00
Ran Benita 4237a20447 symbols: use darray for KeyInfo syms array
The arrays found in KeyInfo are by far the most complicated, so this is
taken one member at a time so as not to break anything.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 13:21:21 +03:00
Ran Benita bc50cdd460 darray: some changes for convenience
- Make darray_free also initialize the array back to an empty state, and
  stop worrying about it everywhere.

- Add darray_mem, to access the underlying memory, which we do manually
  now using &darray_item(arr, 0). This makes a bit more clear when we
  actually mean to take the address of a specific item.

- Add darray_copy, to make a deep copy of a darray.

- Add darray_same, to test whether two darrays have the same underlying
  memory (e.g. if the struct itself was value copied). This should used
  where previously two arrays were compared for pointer equality.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 12:34:57 +03:00
Ran Benita 57f184e218 darray: tweak parameters a bit for better memory usage
Here are some quick numbers from valgrind, running rulescomp only with a
simple, common "us,de" rule set:

before darray: cb047bb
total heap usage: 44,924 allocs, 44,924 frees, 3,162,342 bytes allocated

after darray: c87468e
total heap usage: 52,670 allocs, 52,670 frees, 2,844,517 bytes allocated

tweaking specific inital allocation sizes:
total heap usage: 52,652 allocs, 52,652 frees, 2,841,814 bytes allocated

changing initial alloc = 2 globally
total heap usage: 47,802 allocs, 47,802 frees, 2,833,614 bytes allocated

changing initial alloc = 3 globally
total heap usage: 47,346 allocs, 47,346 frees, 3,307,110 bytes allocated

changing initial alloc = 4 globally
total heap usage: 44,643 allocs, 44,643 frees, 2,853,646 bytes allocated

[ Changing the geometric progression constant from 2 only made things
worse. I tried the golden ratio - not so golden :) ]

The last one is obviously the best, so it was chosen, with the specific
tweaks thrown in as well (these were there before but don't make much
difference). Overall it seems to do better than the previous manual
allocations which is a bit surprising.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 12:34:57 +03:00
Ran Benita 93ef256063 Comment out unused fields in xkb_controls
Until (if) we implement/use them the should take up any (mental) space.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 12:34:57 +03:00
Ran Benita cb631c2de0 Unconstify a few string struct fields
These were made const when the structs were exposed in the API. Now they
are private and we shouldn't mess around with the UNCONSTIFY business.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-09 12:34:57 +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 9baf62f307 Remove configure check for X11 keysym files
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>
2012-06-09 12:34:57 +03:00
Ran Benita 58b030bb90 Move XKB_KEY_NoSymbol to xkbcommon-keysyms.h
This avoids a couple of special cases in the code, and is more
consistent. Since anyone who includes xkbcommon.h also gets
xkbcommon-keysyms.h, and anyone who include xkbcommon-keysyms.h would
want NoSymbol anyway, there's no down side.

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 2e009f69c7 Avoid duplicating keysyms for merge if possible
If we can merge cleanly (i.e. use the entirety of one entry rather than
having to go level by level), then just reuse the existing symbols array
and skip the entire merge process.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-04 16:15:10 +01:00
Daniel Stone d3dfd7deab Use $(top_builddir) rather than relative paths
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-04 16:14:42 +01:00
Daniel Stone 734be50050 Work around stupid automake dependency-tracking bug
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>
2012-06-04 14:06:01 +01:00
Daniel Stone e6ca6fc57d Fix action= NoAction() printing
Print it explicitly, rather than type=0x00, with all the private data
too.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-04 14:04:04 +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
Ran Benita dd1ae1e42f Remove fake support for global group range settings
A symbols file may contain a global, non key specific setting for
the group out-of-range handling method (wrap, clamp, redirect). Only
that:

* Its parsed and kept in the SymbolsInfo, but is not otherwise used in
  any way (it's the same in the real xkbcomp).
* It's not used in any of xkeyboard-config files.
* It's not mentioned in the xkb specs (only the per-key ones).
* It doesn't make much sense anyway.

So remove the struct field, and emit an "unsupported, ignored" warning.
We don't increment the error count because of it, just continue (the
radio group warning just below is changed to do the same - there's no
reason to possibly abort the entire thing for it).

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

Conflicts:

	src/xkbcomp/symbols.c
2012-06-04 13:05:24 +01:00
Daniel Stone 98b155c80a Symbols: Don't include NoSymbols in the map
Instead of using NoSymbol in the map, we use num_syms == 0 to signify
the non-presence of a symbol.  So instead of adding NoSymbol mappings
to the list regardless, detect them and set num_syms == 0.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-04 13:01:33 +01:00
Daniel Stone 28e66a703a Fix multiple errors when merging symbol definitions
We were getting the size calculation wrong, as well as inconsistently
picking a merge strategy.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-04 12:54:54 +01:00
Daniel Stone f43f75fb83 dump 2012-06-02 15:29:21 +01:00
Daniel Stone f531d1e16d keymap-dump: Print NoAction actions too
The failure mode here is a little irritating:
    - server loads map with ISO_Lock action
    - server dumps keymap to string, including:
      interpret ISO_Lock+AnyOfOrAll(None) {
          action= NoAction();
      };
      as we don't (yet) print ISO_Lock actions
    - client parses keymap from string
    - client dumps keymap to string, including:
      interpret ISO_Lock+AnyOfOrAll(None) {
      };
    - this results in a syntax error

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-02 15:25:36 +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 a3ae0e84e4 Pass merge down through indicator creation
To avoid using potentially undefined memory.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-29 16:19:17 +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
Daniel Stone 208d957806 Fix signed vs. unsigned confusion in actions
Some actions could also take relative rather than absolute parameters,
so they really needed to be signed instead of explicitly unsigned.
Oops.

Fixes, e.g., action= MovePtr(x=-1,y=+1), which was reported as
(x=+65535,y=+1).

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-25 18:02:19 +01:00
Ran Benita ccc047c4e0 compat: use darray for acts and key_acts in the server map
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 18:02:40 +03:00
Ran Benita 89c5e88603 keycodes: use darray in KeyNamesInfo
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 15:45:42 +03:00
Ran Benita 07c88b551b symbols: use darray for xkb_sym_map
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 15:20:47 +03:00
Ran Benita 4daa34b5a3 keytypes: use darray for level names
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:24 +03:00
Ran Benita ee990d53a5 symbols: use darray for KeyInfo
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:24 +03:00
Ran Benita dcdbd14925 parser: use darray for keysym list
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:24 +03:00
Ran Benita c65a3596ae keytypes: use darray for xkb_kt_map_entry's
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:24 +03:00
Ran Benita 374b0c9814 alloc: use darray in xkb_key_names
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:24 +03:00
Ran Benita c2ac3a2b20 keytypes: use darray for key types in the client map
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita 561504162f compat: use darray for sym_interprets
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita d0288bb288 context: use darray for include paths
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita ef51b572aa atom: use darray for the node_table
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita 0c271e093a rules: use darray for input line
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita 28bbb7dc51 rules: use darray for rules and groups
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00