platform/upstream/libxkbcommon.git
12 years agoRemove haveSelf include feature
Ran Benita [Wed, 18 Jul 2012 13:30:55 +0000 (16:30 +0300)]
Remove haveSelf include feature

When including a file from another file, its possible to do something
like this:
    include "+some(other)+files"
with the "+" or "|" in the beginning. What will happen then is that
instead of processing the include files separately and then merging into
the existing info, we instead start with the existing info and merge
into it as we go, as if it was written explicitly before the first "+".

It's not particulary clear what this may be useful for. Since it's not
used by xkeyboard-config, not documented anywhere (and google doesn't
bring up anything), completely untested and kind of ugly, remove this
"feature". It most likely never been used.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agotypes: use list instead of CommonInfo in PreserveInfo
Ran Benita [Tue, 17 Jul 2012 12:50:24 +0000 (15:50 +0300)]
types: use list instead of CommonInfo in PreserveInfo

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agotypes: move global static tok_ atoms into KeyTypesInfo
Ran Benita [Tue, 17 Jul 2012 12:39:27 +0000 (15:39 +0300)]
types: move global static tok_ atoms into KeyTypesInfo

The atoms are context-dependent.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agocompat: use list instead of CommonInfo in LEDInfo
Ran Benita [Mon, 16 Jul 2012 21:53:07 +0000 (00:53 +0300)]
compat: use list instead of CommonInfo in LEDInfo

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoUse xkb_group_index_t for group variables throughout
Ran Benita [Tue, 17 Jul 2012 08:03:43 +0000 (11:03 +0300)]
Use xkb_group_index_t for group variables throughout

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRemove _X_EXPORT from xkb_key_get_group/level
Ran Benita [Tue, 17 Jul 2012 08:56:00 +0000 (11:56 +0300)]
Remove _X_EXPORT from xkb_key_get_group/level

We should add them to xkbcommon.h if they need to.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agocompat: use list instead of CommonInfo in SymInterpInfo
Ran Benita [Mon, 16 Jul 2012 21:43:59 +0000 (00:43 +0300)]
compat: use list instead of CommonInfo in SymInterpInfo

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoMove indicators.c code into compat.c
Ran Benita [Mon, 16 Jul 2012 19:45:16 +0000 (22:45 +0300)]
Move indicators.c code into compat.c

It is only used there. Allows some refactoring.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoConvert macros to inline functions
Ran Benita [Mon, 16 Jul 2012 19:15:43 +0000 (22:15 +0300)]
Convert macros to inline functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agokeycodes: use list instead of CommonInfo in IndicatorNameInfo
Ran Benita [Mon, 16 Jul 2012 18:28:25 +0000 (21:28 +0300)]
keycodes: use list instead of CommonInfo in IndicatorNameInfo

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agokeycodes: use list instead of CommonInfo in AliasInfo
Ran Benita [Mon, 16 Jul 2012 18:25:00 +0000 (21:25 +0300)]
keycodes: use list instead of CommonInfo in AliasInfo

Always pass around the KeyNamesInfo which contains the list head.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoMove alias.c functions into keycodes.c
Ran Benita [Mon, 16 Jul 2012 14:53:46 +0000 (17:53 +0300)]
Move alias.c functions into keycodes.c

They are only used in this file.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: don't use CommonInfo in KeyInfo
Ran Benita [Mon, 16 Jul 2012 08:24:48 +0000 (11:24 +0300)]
symbols: don't use CommonInfo in KeyInfo

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: use list for ModMapEntry's
Ran Benita [Mon, 16 Jul 2012 08:09:03 +0000 (11:09 +0300)]
symbols: use list for ModMapEntry's

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoAdd common linked list implementation
Ran Benita [Mon, 16 Jul 2012 08:06:33 +0000 (11:06 +0300)]
Add common linked list implementation

Taken from xserver/include/list.h. The changes made are:
* Drop the xorg_ prefix and some typedef from the end.
* Rename _for_each_entry macros to just _foreach (like darray).
* Rename list_is_empty to list_empty (like darray).
* Add a list_replace function which we use later.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: remove alias info
Ran Benita [Mon, 16 Jul 2012 07:15:53 +0000 (10:15 +0300)]
symbols: remove alias info

It's never used - all of the aliases are added in the keycodes section.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoPass around xkb_key's instead of keycodes
Ran Benita [Sun, 15 Jul 2012 12:55:34 +0000 (15:55 +0300)]
Pass around xkb_key's instead of keycodes

This way we don't need to look up the key every time. We now only deal
with keycodes in the public API and in keycodes.c.

Also adds an xkb_foreach_key macro, which is used a lot.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agomap: verifiy that the keycode is legal
Ran Benita [Sun, 15 Jul 2012 11:35:57 +0000 (14:35 +0300)]
map: verifiy that the keycode is legal

In case someone passes in a bad keycode.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRemove redundant keymap->keys resizes
Ran Benita [Sun, 15 Jul 2012 11:24:54 +0000 (14:24 +0300)]
Remove redundant keymap->keys resizes

The size (i.e. max_keycode) is determined in the keycodes section, which
gets compiled first.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRemove GroupsWidth macro
Ran Benita [Sun, 15 Jul 2012 11:02:36 +0000 (14:02 +0300)]
Remove GroupsWidth macro

Use key->width directly instead.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRemove unused 'groupInfo' in KeyTypeInfo
Ran Benita [Tue, 17 Jul 2012 08:51:32 +0000 (11:51 +0300)]
Remove unused 'groupInfo' in KeyTypeInfo

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoGet rid of group_info
Ran Benita [Sun, 15 Jul 2012 10:51:34 +0000 (13:51 +0300)]
Get rid of group_info

This is 8 bits which hold how many groups the key has, what to do the
key group is out of bound and the group to redirect to if want to. This
may save a few bytes, but is really annoying. So instead, just lay out
the fields separately. We can optimize later in a sane way, with pahole,
bitfields, etc. if we want.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoGet rid of struct xkb_sym_map
Ran Benita [Sun, 15 Jul 2012 10:15:33 +0000 (13:15 +0300)]
Get rid of struct xkb_sym_map

Past its usefulness; put the stuff directly in xkb_key.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoGet rid of struct xkb_key_name
Ran Benita [Sun, 15 Jul 2012 10:00:04 +0000 (13:00 +0300)]
Get rid of struct xkb_key_name

Just embed it directly.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoAdd common xkb_key struct
Ran Benita [Sun, 15 Jul 2012 07:38:05 +0000 (10:38 +0300)]
Add common xkb_key struct

Instead of having a million arrays from the keycode to various
key-specific info in the keymap, add a single struct xkb_key to hold all
of the data for the key in one object. This way we can pass it around,
do some refactoring and make the code simpler. It's also nice to see
everything in one place.

The keys array is still indexed by keycode, which is suboptimal because
there may be a lot of holes (i.e. unused keycodes between min_key_code
and max_key_code). By the end of this series it would be abstracted
enough to replace it by a hash table or similar if there's ever a need.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoReplace KeyInfo 'key' variable name by 'keyi'
Ran Benita [Sun, 15 Jul 2012 09:48:11 +0000 (12:48 +0300)]
Replace KeyInfo 'key' variable name by 'keyi'

We want to reserve the name 'key' for something else.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoReplace xkb_keycode_t 'key' variable name by 'kc'
Ran Benita [Sun, 15 Jul 2012 08:52:54 +0000 (11:52 +0300)]
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>
12 years agoConvert indecipherable macros to inline functions
Ran Benita [Sun, 15 Jul 2012 08:37:54 +0000 (11:37 +0300)]
Convert indecipherable macros to inline functions

This was fun.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: split initialization code from CompileSymbols
Ran Benita [Sat, 14 Jul 2012 22:59:01 +0000 (01:59 +0300)]
symbols: split initialization code from CompileSymbols

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoMove per_key_repeats and enabled_ctrls to keymap
Ran Benita [Sat, 14 Jul 2012 22:45:34 +0000 (01:45 +0300)]
Move per_key_repeats and enabled_ctrls to keymap

All of the per-key data and global flags are now visible directly in the
keymap.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoGet rid of xkb_key_names
Ran Benita [Sat, 14 Jul 2012 22:31:34 +0000 (01:31 +0300)]
Get rid of xkb_key_names

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoGet rid of xkb_indicator
Ran Benita [Sat, 14 Jul 2012 21:46:31 +0000 (00:46 +0300)]
Get rid of xkb_indicator

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoGet rid of xkb_compat_map
Ran Benita [Sat, 14 Jul 2012 21:39:15 +0000 (00:39 +0300)]
Get rid of xkb_compat_map

Same as xkb_{client,server}_map which were already removed.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoGet rid of xkb_server_map
Ran Benita [Sat, 14 Jul 2012 21:26:28 +0000 (00:26 +0300)]
Get rid of xkb_server_map

Same as xkb_client_map which was removed before.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoGet rid of xkb_client_map
Ran Benita [Sat, 14 Jul 2012 21:06:11 +0000 (00:06 +0300)]
Get rid of xkb_client_map

We don't make this distinction anymore, and the separate allocations
just make it harder to reason about. Since we require that all of
symbols, types, compat etc. be present, we should just put stuff
directly in the keymap struct.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRun source tree through uncrustify
Daniel Stone [Tue, 17 Jul 2012 09:20:15 +0000 (10:20 +0100)]
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>
12 years agoFix typo in out of range group calculation
Ran Benita [Sun, 15 Jul 2012 14:35:35 +0000 (17:35 +0300)]
Fix typo in out of range group calculation

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRemove unused control num_groups
Ran Benita [Sat, 14 Jul 2012 16:53:13 +0000 (19:53 +0300)]
Remove unused control num_groups

We have xkb_map_num_groups for that.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoConvert missed enum merge_mode variables
Ran Benita [Sat, 14 Jul 2012 12:14:44 +0000 (15:14 +0300)]
Convert missed enum merge_mode variables

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoFix fileID mess
Ran Benita [Sat, 14 Jul 2012 12:19:12 +0000 (15:19 +0300)]
Fix fileID mess

A few problems here:
* In e.g. keycodes.c the fileID field of the Info struct was never
  initialized to the id of the appropriate file, so it was always 0.
  There's some code which uses it, mostly for warnings.
* Some of the fileID fields were unsigned char, which overflows several
  times, seeing as the ID in some of our tests can get > 1000 (because
  we reuse the context).
* Some sign mismatches.
* fileID vs file_id.

Hopefully this fixes everything. I doubt this stuff had ever worked as
intended, in xkbcomp or otherwise.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agopath: fix error message
Ran Benita [Sat, 14 Jul 2012 09:37:25 +0000 (12:37 +0300)]
path: fix error message

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoMake compile_keymap a little nicer
Ran Benita [Fri, 13 Jul 2012 22:12:50 +0000 (01:12 +0300)]
Make compile_keymap a little nicer

Just using the fact that we must have all of the components, without
optional ones.
Also fixes a memleak on the way, by making the functions which allocate
the XkbFiles to free them, which is easier to get right.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoMove CompileKeymap into xkbcomp.c
Ran Benita [Fri, 13 Jul 2012 21:27:19 +0000 (00:27 +0300)]
Move CompileKeymap into xkbcomp.c

It's nicer to see the code where its used. Removes keymap.c.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRename KSIsLower/Upper and move to keysym.c
Ran Benita [Fri, 13 Jul 2012 15:55:10 +0000 (18:55 +0300)]
Rename KSIsLower/Upper and move to keysym.c

Seems like a more natural place, and allows to remove the src/misc.c
file.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRemove MERGE_ALT_FORM merge mode
Ran Benita [Fri, 13 Jul 2012 15:34:11 +0000 (18:34 +0300)]
Remove MERGE_ALT_FORM merge mode

The mode comes from the "alternate" keyword, which is unused in
xkeyboard-config and mostly undocumented. Its purpose is to allow to
assign the same key name to multiple key codes, which is not allowed
otherwise (and doesn't make much sense). The xkblib specification
implies that this was part of the overlay functionality, which we also
no longer support.

If we do encounter this keyword, we just treat it as MERGE_DEFAULT. The
keycodes.c code will detect a collision and will ignore all but the
first key code (and the error count is not incremented).

Some peripheral code is also removed as a result.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoMove InitCanonicalKeyTypes to keytypes.c
Ran Benita [Fri, 13 Jul 2012 14:51:26 +0000 (17:51 +0300)]
Move InitCanonicalKeyTypes to keytypes.c

It's only got one call site and it's in keytypes.c, so move it there and
make it static.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRemove xkb_kt_map_entry::active
Ran Benita [Fri, 13 Jul 2012 14:37:31 +0000 (17:37 +0300)]
Remove xkb_kt_map_entry::active

Takes the advice of acdad6058d52dc8a3e724dc95448300850d474f2 and removes
this field, since its not used anymore now.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoMove ComputeEffectiveMap code and avoid some duplication
Ran Benita [Fri, 13 Jul 2012 14:31:30 +0000 (17:31 +0300)]
Move ComputeEffectiveMap code and avoid some duplication

The ComputeEffectiveMap function is only called from keytypes.c, with
the last argument NULL, so we can move it there and remove some code.
The function XkbcVirtualModsToRealMods, of which the above is the only
user, is already implemented more simply in compat.c, so make this one
non-static and use it. This leaves src/xkb.c empty, so remove it.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoremove unused function xkb_canonicalise_components
Ran Benita [Fri, 13 Jul 2012 14:10:48 +0000 (17:10 +0300)]
remove unused function xkb_canonicalise_components

commit 46441b1184dfa8553409d493ae6336aabb900d79 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>
12 years agocompat: fix XkbSI_AllOf matching condition
Ran Benita [Fri, 13 Jul 2012 11:40:14 +0000 (14:40 +0300)]
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>
12 years agoFindAutomaticType: Add FIXME
Daniel Stone [Thu, 12 Jul 2012 23:40:25 +0000 (00:40 +0100)]
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>
12 years agoAdd multiple-keysyms-per-level to test data
Daniel Stone [Thu, 12 Jul 2012 23:39:34 +0000 (00:39 +0100)]
Add multiple-keysyms-per-level to test data

Make sure this keeps on working.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
12 years agorulescomp: Fix benchmark runs
Daniel Stone [Thu, 12 Jul 2012 23:32:41 +0000 (00:32 +0100)]
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>
12 years agotests: Update dump.data for recent fixes
Daniel Stone [Thu, 12 Jul 2012 23:12:57 +0000 (00:12 +0100)]
tests: Update dump.data for recent fixes

Makes the test pass again.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
12 years agodump: add back kccgst names
Ran Benita [Wed, 11 Jul 2012 13:16:20 +0000 (16:16 +0300)]
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>
12 years agoAdd Cyrillic and Greek to case-checking
Daniel Stone [Thu, 12 Jul 2012 23:10:23 +0000 (00:10 +0100)]
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>
12 years agodump: a few more tweaks to match xkbcomp output
Ran Benita [Wed, 11 Jul 2012 13:35:43 +0000 (16:35 +0300)]
dump: a few more tweaks to match xkbcomp output

Only uppercase / lowercase stuff.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: fix bug in modifier_map handling
Ran Benita [Thu, 12 Jul 2012 16:28:52 +0000 (19:28 +0300)]
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>
12 years agodump: use KeyNameText instead of copying
Ran Benita [Thu, 12 Jul 2012 14:54:09 +0000 (17:54 +0300)]
dump: use KeyNameText instead of copying

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoImport dataset into test/data/
Daniel Stone [Thu, 12 Jul 2012 13:42:31 +0000 (14:42 +0100)]
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>
12 years agoAdd a library of common test functions
Daniel Stone [Thu, 12 Jul 2012 13:15:08 +0000 (14:15 +0100)]
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>
12 years agoMove test data files to test/data/keymaps
Daniel Stone [Thu, 12 Jul 2012 11:02:19 +0000 (12:02 +0100)]
Move test data files to test/data/keymaps

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
12 years agoMake BindIndicators static
Daniel Stone [Tue, 3 Jul 2012 20:22:09 +0000 (21:22 +0100)]
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>
12 years agoChange BindIndicators return to void
Daniel Stone [Tue, 3 Jul 2012 20:17:11 +0000 (21:17 +0100)]
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>
12 years agoRemove 'unboundRtrn' argument from BindIndicators
Daniel Stone [Tue, 3 Jul 2012 20:15:28 +0000 (21:15 +0100)]
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>
12 years agoRemove 'force' argument from BindIndicators
Daniel Stone [Tue, 3 Jul 2012 20:13:11 +0000 (21:13 +0100)]
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>
12 years agoEnlarge keysym name buffers and mention in comment
Ran Benita [Wed, 11 Jul 2012 15:00:31 +0000 (18:00 +0300)]
Enlarge keysym name buffers and mention in comment

The longest keysym is 27 chars long.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agotest/dump: output commentary to stderr
Ran Benita [Wed, 11 Jul 2012 13:23:35 +0000 (16:23 +0300)]
test/dump: output commentary to stderr

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: fix bug in symbol merging
Ran Benita [Wed, 11 Jul 2012 18:37:59 +0000 (21:37 +0300)]
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>
12 years agokeyseq: add a failing group-switching test
Ran Benita [Wed, 11 Jul 2012 11:12:12 +0000 (14:12 +0300)]
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>
12 years agorules: fix parsing of multiple options
Ran Benita [Wed, 11 Jul 2012 11:08:28 +0000 (14:08 +0300)]
rules: fix parsing of multiple options

This was broken by commit 18d331b86b4942ba54fe087ca07e47c9383d768b
(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>
12 years agokeymap: remove redundant check
Ran Benita [Sat, 30 Jun 2012 21:45:20 +0000 (00:45 +0300)]
keymap: remove redundant check

This is handled above in the LEGAL_FILE_TYPES check.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agostate: fix base mod set/clear behavior
Ran Benita [Fri, 29 Jun 2012 21:07:09 +0000 (00:07 +0300)]
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>
12 years agoTiny reformatting
Ran Benita [Fri, 29 Jun 2012 19:25:27 +0000 (22:25 +0300)]
Tiny reformatting

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agorules: remove support for keymap rule
Ran Benita [Fri, 29 Jun 2012 21:49:41 +0000 (00:49 +0300)]
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>
12 years agoRemove _X_EXPORT from xkb_map_new_from_kccgst
Ran Benita [Fri, 29 Jun 2012 21:37:12 +0000 (00:37 +0300)]
Remove _X_EXPORT from xkb_map_new_from_kccgst

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoxkbcomp: remove useless function XkbChooseMap
Ran Benita [Fri, 29 Jun 2012 16:26:01 +0000 (19:26 +0300)]
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>
12 years agocompat: move some unclear code where it belongs
Ran Benita [Fri, 29 Jun 2012 14:45:47 +0000 (17:45 +0300)]
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>
12 years agoUse enum for merge mode
Ran Benita [Fri, 29 Jun 2012 14:31:10 +0000 (17:31 +0300)]
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>
12 years agoUse enum for file types
Ran Benita [Fri, 29 Jun 2012 14:05:33 +0000 (17:05 +0300)]
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>
12 years agokeymap: simplify legal/required logic a bit
Ran Benita [Fri, 29 Jun 2012 13:04:55 +0000 (16:04 +0300)]
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>
12 years agoUse void* instead of old style char* in CommonInfo functions
Ran Benita [Tue, 26 Jun 2012 21:22:31 +0000 (00:22 +0300)]
Use void* instead of old style char* in CommonInfo functions

Removes some annoying casts.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoDon't set explicit repeat masks when derived
Daniel Stone [Fri, 22 Jun 2012 15:08:05 +0000 (16:08 +0100)]
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>
12 years agoDon't ignore inactive type entries
Daniel Stone [Fri, 22 Jun 2012 15:03:17 +0000 (16:03 +0100)]
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>
12 years agostate: Add more comprehensive repeating test
Daniel Stone [Fri, 22 Jun 2012 14:29:47 +0000 (15:29 +0100)]
state: Add more comprehensive repeating test

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
12 years agoAdd xkb_key_repeats
Daniel Stone [Fri, 22 Jun 2012 14:27:05 +0000 (15:27 +0100)]
Add xkb_key_repeats

Does what it says on the box.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
12 years agoWork out a default repeat for all keys
Daniel Stone [Fri, 22 Jun 2012 14:26:07 +0000 (15:26 +0100)]
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>
12 years agoAdd a test for the results of key sequences
Ran Benita [Tue, 10 Apr 2012 18:20:27 +0000 (21:20 +0300)]
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>
12 years agoutils: remove unused recalloc and related macros
Ran Benita [Wed, 6 Jun 2012 07:44:22 +0000 (10:44 +0300)]
utils: remove unused recalloc and related macros

Their use is superseded by darray everywhere now.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agostate: use darray for filters
Ran Benita [Wed, 6 Jun 2012 07:38:45 +0000 (10:38 +0300)]
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>
12 years agosymbols: use darray in struct xkb_sym_map
Ran Benita [Wed, 6 Jun 2012 07:01:43 +0000 (10:01 +0300)]
symbols: use darray in struct xkb_sym_map

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: use darray for KeyInfo acts
Ran Benita [Tue, 5 Jun 2012 22:22:52 +0000 (01:22 +0300)]
symbols: use darray for KeyInfo acts

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: use darray for KeyInfo symsMapNumEntries
Ran Benita [Tue, 5 Jun 2012 21:57:42 +0000 (00:57 +0300)]
symbols: use darray for KeyInfo symsMapNumEntries

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: use darray for KeyInfo symsMapIndex
Ran Benita [Tue, 5 Jun 2012 21:39:23 +0000 (00:39 +0300)]
symbols: use darray for KeyInfo symsMapIndex

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: remove sizeSyms array from KeyInfo
Ran Benita [Tue, 5 Jun 2012 16:25:23 +0000 (19:25 +0300)]
symbols: remove sizeSyms array from KeyInfo

This information is kept inside the darray now.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: use darray for KeyInfo syms array
Ran Benita [Tue, 5 Jun 2012 16:09:01 +0000 (19:09 +0300)]
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>
12 years agodarray: some changes for convenience
Ran Benita [Tue, 5 Jun 2012 15:46:24 +0000 (18:46 +0300)]
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>
12 years agodarray: tweak parameters a bit for better memory usage
Ran Benita [Wed, 30 May 2012 12:55:21 +0000 (15:55 +0300)]
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>
12 years agoComment out unused fields in xkb_controls
Ran Benita [Fri, 8 Jun 2012 06:54:08 +0000 (09:54 +0300)]
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>
12 years agoUnconstify a few string struct fields
Ran Benita [Fri, 8 Jun 2012 06:25:38 +0000 (09:25 +0300)]
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>