Commit Graph

762 Commits (41d97df9515770e753db6cd819727cec44c59d1b)

Author SHA1 Message Date
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
Ran Benita b7c0737a94 compat: fix XkbSI_AllOf matching condition
To quote the spec:

XkbSI_AllOf
    All of the bits that are on in mods must be set, but others may be
    set as well.

Here "mods" refers to interp->mods. This matches xserver/libX11.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-13 19:06:54 +03:00
Daniel Stone 6e7d1678ba FindAutomaticType: Add FIXME
It doesn't play well with multiple keysyms per level right now.  But
that's OK, because no-one really uses them.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-13 00:40:25 +01: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
Daniel Stone 2ec0a22d55 Add Cyrillic and Greek to case-checking
Evidently good to have on its own, but also fixes a regression from
xkbcomp where we'd identify implicitly-typed Cyrillic keys as TWO_LEVEL
rather than ALPHABETIC.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-13 00:10:23 +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
Ran Benita fedcf3705b dump: use KeyNameText instead of copying
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-12 18:07:56 +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
Daniel Stone b10f924b0c Make BindIndicators static
Since BindIndicators was only ever called immediately after
CopyIndicatorMapDefs, move it up in the file and turn it into a static
function, which avoids the need to ever pass the unbound LEDs around.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-12 09:42:27 +01:00
Daniel Stone d38d16e113 Change BindIndicators return to void
Since it could only ever return true, which avoids a totally unnecessary
cleanup path.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-12 09:42:27 +01:00
Daniel Stone 9116e02d6f Remove 'unboundRtrn' argument from BindIndicators
It was only ever passed as NULL from its single callsite, so just remove
it and be done with it.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-12 09:42:27 +01:00
Daniel Stone cfed7960ad Remove 'force' argument from BindIndicators
It was always true in the one callsite, so just remove the other
branches.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-12 09:42:27 +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 e4d4de8c9e symbols: fix bug in symbol merging
When we merge two KeyInfo's (belonging to the same keycode), we may take
a shortcut from copying if we see that the merged keys will be exactly
like those in one of the two KeyInfo's. In the case where we take the
symbols from the KeyInfo we are *not* merging into, we need to copy
the three arrays:
    syms[group], symsMapNumEntries[group], symsMapIndex[group]
The code currently only copies the first one, so if there's a merge
conflict some levels may seem to disappear (i.e. have a NoSymbol
keysym).

This fixes the failing test added in c8d6bba.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-12 09:42:12 +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 8ff984871b keymap: remove redundant check
This is handled above in the LEGAL_FILE_TYPES check.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-01 10:21:01 +03: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 13f030baf2 Tiny reformatting
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-01 00:51:56 +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
Ran Benita 337c3007ac Remove _X_EXPORT from xkb_map_new_from_kccgst
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-01 00:51:56 +03:00
Ran Benita ddb0ff9d02 xkbcomp: remove useless function XkbChooseMap
compile_keymap can only be passes a single keymap file now, from all
code paths leading to it. So this function doesn't do anything.

The remaining check is performed inside CompileKeymap, so we can remove
it as well; compile_keymap doesn't do much now.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-01 00:51:56 +03:00
Ran Benita 7111eb8e8a compat: move some unclear code where it belongs
It seems like at some point it was needed to break the abstraction and
perform this piece of code in the context above CompileCompatMap. The
extra argument and the typedef look strange now, and doesn't seem to be
needed any more, so move them back.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-01 00:51:56 +03:00
Ran Benita 213dcf686f Use enum for merge mode
The merge mode shows up in a lot of functions, so it's useful to give it
a distinct type.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-01 00:51:56 +03:00
Ran Benita 48b4d30aa3 Use enum for file types
enums are nice for some type safety and readability. This one also
removes the distinction between file type mask / file type index and
some naming consistency.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-01 00:51:56 +03:00
Ran Benita 8f257397af keymap: simplify legal/required logic a bit
Now that we've consolidated on the keymap file type, this code only
serves to confuse.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-01 00:51:03 +03:00
Ran Benita f637d35a86 Use void* instead of old style char* in CommonInfo functions
Removes some annoying casts.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-06-27 00:22:31 +03:00
Daniel Stone 2cb6c35b87 Don't set explicit repeat masks when derived
If we've only derived that a key should repeat, rather than had it
explicitly specified, don't set the explicit member.  Fixes the dump
test.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-22 16:08:05 +01:00
Daniel Stone acdad6058d Don't ignore inactive type entries
An entry for a type will only get marked as active if a virtual modifier
can be directly mapped to it, and not if an action indirectly leads to
it (e.g. LevelThree).  We don't really need this test since entries which
can never be triggered ... won't be triggered.

The entire map->active thing should probably just go away.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-22 16:05:45 +01: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
Daniel Stone fe89d03154 Work out a default repeat for all keys
Our early exit in ApplyInterpsToKey meant we weren't hitting the code
that's supposed to set a sensible default autorepeat value for most
keys.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-22 15:26:07 +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 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