platform/upstream/libxkbcommon.git
11 years agosymbols: refactor CoypSymbolsDef
Ran Benita [Thu, 13 Sep 2012 18:06:36 +0000 (21:06 +0300)]
symbols: refactor CoypSymbolsDef

To make it easier to follow.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: FindAutomaticType only needs the context
Ran Benita [Thu, 13 Sep 2012 18:06:10 +0000 (21:06 +0300)]
symbols: FindAutomaticType only needs the context

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeyseq: test that de(neo) is working properly
Ran Benita [Thu, 13 Sep 2012 08:49:02 +0000 (11:49 +0300)]
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>
11 years agosymbols: store actions from symbols in the right offset
Ran Benita [Thu, 13 Sep 2012 17:59:27 +0000 (20:59 +0300)]
symbols: store actions from symbols in the right offset

This regression was introduced in 93ce9c7d4f7. This meant that actions
specified inside key {} statments were always going to the first group.
But actions are almost never specified in xkb_symbols so this wasn't
noticed.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: remove CopyKeyInfo
Ran Benita [Wed, 12 Sep 2012 22:33:49 +0000 (01:33 +0300)]
symbols: remove CopyKeyInfo

The code is better without it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: fix real/alias key merge ordering bug
Ran Benita [Wed, 12 Sep 2012 20:51:19 +0000 (23:51 +0300)]
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>
11 years agosymbols: add CopySymbolsToKeymap
Ran Benita [Wed, 12 Sep 2012 20:29:49 +0000 (23:29 +0300)]
symbols: add CopySymbolsToKeymap

Like in the other sections.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: remove mention of keycodes in CopySymbolsDef
Ran Benita [Wed, 12 Sep 2012 18:32:25 +0000 (21:32 +0300)]
symbols: remove mention of keycodes in CopySymbolsDef

Since now we only use the keycode in this function for logging, it's
better not to mention the keycode at all because the XkbKeyGetKeycode
macro is implemented using a dirty hack 0_0
The key name is sufficient to determine uniquely where to look.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: remove unneeded recursion form CopySymbolsDef
Ran Benita [Wed, 12 Sep 2012 18:24:28 +0000 (21:24 +0300)]
symbols: remove unneeded recursion form CopySymbolsDef

This function does some funky stuff, which, as far as I can tell, was
needed to support the functionality of giving different keycodes the
same name and thus make them duplicates (MERGE_ALT_FORM). This stuff was
removed as useless in 0765064b3, but this leftover wasn't noticed.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: add LevelInfo
Ran Benita [Tue, 11 Sep 2012 11:47:01 +0000 (14:47 +0300)]
symbols: add LevelInfo

Add a LevelInfo to hold a single array of level specific info inside
a GroupInfo, instead of keeping the acts, symsMapIndex and
symsMapNumEntries arrays and the numLevels field separate and in sync.
This simplifies the code, and goes a long way toward making  the
key-merging code somewhat understandable. Also uses less memory.

Note that the syms array is still in GroupInfo for now, with the levels
holding offsets into it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: make xkb_key::syms a plain array
Ran Benita [Tue, 11 Sep 2012 13:14:16 +0000 (16:14 +0300)]
symbols: make xkb_key::syms a plain array

It's never resized.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: shorten symsMapNumEntries to uint from size_t
Ran Benita [Mon, 10 Sep 2012 19:02:18 +0000 (22:02 +0300)]
symbols: shorten symsMapNumEntries to uint from size_t

size_t is too wide for this in 64-bit machines.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: consolidate group merging in MergeGroups
Ran Benita [Tue, 11 Sep 2012 06:43:08 +0000 (09:43 +0300)]
symbols: consolidate group merging in MergeGroups

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: add GroupInfo
Ran Benita [Mon, 10 Sep 2012 10:34:36 +0000 (13:34 +0300)]
symbols: add GroupInfo

GroupInfo keeps all of the info for a specific group in one struct.
This is the old array-of-structures vs. structure-of-arrays, but in this
case readability wins. It would also help with lifting the
XkbNumKbdGroups limit, because we only have to worry about one array
(instead of 6).

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap-dump: don't write spaces between multiple-syms-per-level
Ran Benita [Wed, 12 Sep 2012 13:39:54 +0000 (16:39 +0300)]
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>
11 years agosymbols: use darray for ModMapEntry instead of list
Ran Benita [Mon, 10 Sep 2012 20:18:58 +0000 (23:18 +0300)]
symbols: use darray for ModMapEntry instead of list

There's no need for a list here.
[This also happens to be the last place list.h is used.]

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: remove unused next field from xkb_filter
Ran Benita [Mon, 10 Sep 2012 20:24:19 +0000 (23:24 +0300)]
state: remove unused next field from xkb_filter

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoUpdate COPYING
Daniel Stone [Wed, 12 Sep 2012 15:58:57 +0000 (16:58 +0100)]
Update COPYING

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoCopyright updates
Daniel Stone [Wed, 12 Sep 2012 15:54:07 +0000 (16:54 +0100)]
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>
11 years agoutils: Replace DEC copyright with Ran's
Daniel Stone [Tue, 11 Sep 2012 16:00:38 +0000 (17:00 +0100)]
utils: Replace DEC copyright with Ran's

This is not something I do often, but I have good reason here ...

utils.h has been totally rewritten since import, and now contains no
original DEC content.  Everything in here has been added by Ran, and I
do not believe that any lingering content from previous iterations is
substantial enough as to be copyrightable.

Replace DEC's copyright (and license with hostile advertising clause)
with Ran's boilerplate copyright and license statement.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoxkbcommon-keysyms: Add header protection
David Herrmann [Tue, 11 Sep 2012 15:49:04 +0000 (16:49 +0100)]
xkbcommon-keysyms: Add header protection

As there is currently no stable release of xkbcommon, other projects might
want to include a copy of the keysyms so they can be used even though
libxkbcommon may not be available on the machine. However, if xkbcommon.h
is still included, conflicts will occur. Hence, to avoid nasty hacks,
simply include a header protection in xkbcommon upstream.

[daniels: Added protection to Makefile.am's update-keysyms, as well as
          XKB_KEY_NoSymbol, and a comment noting that it shouldn't be
          updated directly.]

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoAndroid.mk: Remove unnecessary for loop
Helio Chissini de Castro [Tue, 11 Sep 2012 14:11:35 +0000 (15:11 +0100)]
Android.mk: Remove unnecessary for loop

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoRemove unused ExprResolveKeyName
Daniel Stone [Tue, 11 Sep 2012 14:09:37 +0000 (15:09 +0100)]
Remove unused ExprResolveKeyName

The only user was removed in 314965b1.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoConstify keysym <-> Unicode lookup table
Daniel Stone [Tue, 11 Sep 2012 13:52:27 +0000 (14:52 +0100)]
Constify keysym <-> Unicode lookup table

Before:
  text     data     bss     dec     hex filename
234422    11288    2304  248014   3c8ce obj-amd64/.libs/libxkbcommon.so.0.0.0

After:
  text     data     bss     dec     hex filename
240694     5016    2304  248014   3c8ce obj-amd64/.libs/libxkbcommon.so.0.0.0

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoxkbcommon.h build fix for missing stdarg.h
Pekka Paalanen [Mon, 20 Aug 2012 12:34:07 +0000 (15:34 +0300)]
xkbcommon.h build fix for missing stdarg.h

In file included from external/collabora/libxkbcommon/src/xkb-priv.h:87,
                 from external/collabora/libxkbcommon/src/xkbcomp/xkbcomp.h:30,
                 from external/collabora/libxkbcommon/src/xkbcomp/xkbcomp-priv.h:30,
                 from external/collabora/libxkbcommon/src/xkbcomp/action.h:30,
                 from external/collabora/libxkbcommon/src/xkbcomp/action.c:27:
external/collabora/libxkbcommon/xkbcommon/xkbcommon.h:279: error: expected declaration specifiers or '...' before 'va_list'

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoUpdate Android.mk
Daniel Stone [Tue, 11 Sep 2012 13:27:54 +0000 (14:27 +0100)]
Update Android.mk

Squashed from commits by Helio Chissini de Castro
<helio.chissini.de.castro@collabora.co.uk> and Pekka Paalanen
<ppaalanen@gmail.com>.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: drop dependency
Daniel Stone [Tue, 11 Sep 2012 13:10:41 +0000 (14:10 +0100)]
kbproto unentanglement: drop dependency

\o\ \o/ /o/

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: XkbGeomPtsPerMM
Daniel Stone [Tue, 11 Sep 2012 13:09:20 +0000 (14:09 +0100)]
kbproto unentanglement: XkbGeomPtsPerMM

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: XkbExplicit*Mask
Daniel Stone [Tue, 11 Sep 2012 11:35:24 +0000 (12:35 +0100)]
kbproto unentanglement: XkbExplicit*Mask

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: XkbSI_AutoRepeat
Daniel Stone [Tue, 11 Sep 2012 11:32:18 +0000 (12:32 +0100)]
kbproto unentanglement: XkbSI_AutoRepeat

That was the only interp flag, so just turn it into a straight boolean.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: XkbSI match flags
Daniel Stone [Tue, 11 Sep 2012 11:28:29 +0000 (12:28 +0100)]
kbproto unentanglement: XkbSI match flags

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: control actions
Daniel Stone [Tue, 11 Sep 2012 11:20:21 +0000 (12:20 +0100)]
kbproto unentanglement: control actions

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: XkbMaxShiftLevel
Daniel Stone [Mon, 10 Sep 2012 20:05:04 +0000 (21:05 +0100)]
kbproto unentanglement: XkbMaxShiftLevel

... by removing its only use.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: Xkb{Wrap,Clamp,Redirect}IntoRange
Daniel Stone [Mon, 10 Sep 2012 19:44:52 +0000 (20:44 +0100)]
kbproto unentanglement: Xkb{Wrap,Clamp,Redirect}IntoRange

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoactions: Remove PointerDefault affect field
Daniel Stone [Mon, 10 Sep 2012 19:40:05 +0000 (20:40 +0100)]
actions: Remove PointerDefault affect field

This was always set to affect the default button, so no need for it.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: action flags
Daniel Stone [Mon, 10 Sep 2012 19:38:46 +0000 (20:38 +0100)]
kbproto unentanglement: action flags

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: XkbLC_*
Daniel Stone [Mon, 10 Sep 2012 19:16:05 +0000 (20:16 +0100)]
kbproto unentanglement: XkbLC_*

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: XkbIM_*
Daniel Stone [Mon, 10 Sep 2012 19:07:54 +0000 (20:07 +0100)]
kbproto unentanglement: XkbIM_*

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: action types
Daniel Stone [Mon, 10 Sep 2012 18:23:16 +0000 (19:23 +0100)]
kbproto unentanglement: action types

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoRemove deprecated actions
Daniel Stone [Tue, 21 Aug 2012 13:40:51 +0000 (14:40 +0100)]
Remove deprecated actions

We didn't do anything with ISO_Lock, ActionMessage, RedirectKey, and the
device-specifying variants of the pointer actions, so remove those.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: XkbNumVirtualMods
Daniel Stone [Tue, 21 Aug 2012 11:48:20 +0000 (12:48 +0100)]
kbproto unentanglement: XkbNumVirtualMods

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto unentanglement: XkbNumIndicators
Daniel Stone [Tue, 21 Aug 2012 11:47:28 +0000 (12:47 +0100)]
kbproto unentanglement: XkbNumIndicators

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto untanglement: XkbKbdNumGroups
Daniel Stone [Tue, 21 Aug 2012 11:45:03 +0000 (12:45 +0100)]
kbproto untanglement: XkbKbdNumGroups

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agokbproto untanglement: XkbKeyNameLength
Daniel Stone [Tue, 21 Aug 2012 10:21:19 +0000 (11:21 +0100)]
kbproto untanglement: XkbKeyNameLength

Define it ourselves as XKB_KEY_NAME_LENGTH and use that, instead of the
one from XKB.h.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agorules: use goto instead of state variable
Ran Benita [Tue, 28 Aug 2012 15:04:25 +0000 (18:04 +0300)]
rules: use goto instead of state variable

There's no noticeable speed difference, but I think it's nicer and more
explicit than the previous code. Some people just don't like goto,
though..

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agorules: rewrite
Ran Benita [Sun, 26 Aug 2012 05:54:31 +0000 (08:54 +0300)]
rules: rewrite

Rewrite the rules file parser for clarity, performance and memory usage
reduction. The previous implementation was quite hard to navigate and
did a lot of unnecessary work and copying.
This implementation keeps along just the state necessary, and doesn't
perform any copying of the file's content (although the entire file is
mmap'ed as before). Hopefully it's also easier to understand, has better
documentation, and better error checking and reporting. We try to
reproduce the previous behavior in every case.

Note: the diff is pretty confusing; it's likely better to look at the
file directly.

Benchmarks:
    On an old 32-bit Intel processor.
    gcc -O2 -pg
    ./test/rulescomp bench
    grof test/rulescomp

    Before:
        compiled 1000 keymaps in 14.863564304s
        %   cumulative   self              self     total
        time   seconds   seconds    calls  ms/call  ms/call  name
        49.33      4.43     4.43 30610000     0.00     0.00  yylex
        17.93      6.04     1.61    31000     0.05     0.22  yyparse
        6.57      6.63     0.59     1000     0.59     0.59  load_rules
        3.23      6.92     0.29  3637000     0.00     0.00  AppendStmt
        2.45      7.14     0.22   472000     0.00     0.00  AddKeySymbols
        2.12      7.33     0.19  3591000     0.00     0.00  atom_intern
        2.12      7.52     0.19   518000     0.00     0.00  FindNamedKey
        2.00      7.70     0.18   230000     0.00     0.00  FreeStmt
        1.78      7.86     0.16     1000     0.16     0.17  UpdateModifiersFromCompat
        1.34      7.98     0.12   732000     0.00     0.00  AddKeyName
        1.34      8.10     0.12                             __x86.get_pc_thunk.bx

    After:
        compiled 1000 keymaps in 13.874666269s
        %   cumulative   self              self     total
        time   seconds   seconds    calls  ms/call  ms/call  name
        49.82      4.26     4.26 30610000     0.00     0.00  yylex
        22.22      6.16     1.90    31000     0.06     0.22  yyparse
        2.92      6.41     0.25  3591000     0.00     0.00  atom_intern
        2.57      6.63     0.22     1000     0.22     0.25  xkb_components_from_rules
        2.11      6.81     0.18  3637000     0.00     0.00  AppendStmt
        2.11      6.99     0.18   230000     0.00     0.00  FreeStmt
        1.99      7.16     0.17   518000     0.00     0.00  FindNamedKey
        1.99      7.33     0.17     1000     0.17     0.17  UpdateModifiersFromCompat
        1.99      7.50     0.17                             __x86.get_pc_thunk.bx
        1.52      7.63     0.13   150000     0.00     0.00  AddInterp
        1.40      7.75     0.12   472000     0.00     0.00  AddKeySymbols

    On a newer 64-bit Intel processor.
    gcc -O2
    ./test/rules-file bench

    Before:
        processed 20000 times in 15.940546625s

    After:
        processed 20000 times in 5.295026345s

Allocations:
    gcc -O2
    valgrind test/rulescomp

    Before:
    total heap usage: 257,519 allocs, 257,519 frees, 14,766,529 bytes allocated

    After:
    total heap usage: 240,756 allocs, 240,756 frees, 14,007,886 bytes allocated

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: make LEDInfo a wrapper around xkb_indicator_map
Ran Benita [Tue, 4 Sep 2012 14:40:09 +0000 (17:40 +0300)]
compat: make LEDInfo a wrapper around xkb_indicator_map

instead of duplicating the fields. The same is done in SymInterpInfo
which wraps xkb_sym_interpret.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoFold keymap->indicator_names into keymap->indicators
Ran Benita [Tue, 4 Sep 2012 14:20:46 +0000 (17:20 +0300)]
Fold keymap->indicator_names into keymap->indicators

This makes sense, since giving a name to an indicator 'activates' the
indicator_map in that index.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoUnify some string tables from xkbcomp, text and keymap-dump
Ran Benita [Sun, 2 Sep 2012 18:45:42 +0000 (21:45 +0300)]
Unify some string tables from xkbcomp, text and keymap-dump

We move the LookupEntry struct from expr.h to text.h, along with most of
the lookup tables. This makes them available everywhere.
Looking up a value in the LookupEntry format is slower than direct index
mapping, but it allows multiple names per value (with the canonical one
being first) and "all"- and "none"-type masks. These functions are not
used anywhere efficiency matters.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoConvert rest of names in xkb_keymap back to atoms
Ran Benita [Fri, 31 Aug 2012 16:26:51 +0000 (19:26 +0300)]
Convert rest of names in xkb_keymap back to atoms

These were kept as atoms, but since the keymap was exposed in the API,
we converted them to strings; no the keymap is no longer exposed, so we
can go back to atoms. They make the keymap smaller (at least on 64-bit
machines) and the comparisons faster.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: make ResolveString return an atom
Ran Benita [Fri, 31 Aug 2012 16:05:49 +0000 (19:05 +0300)]
expr: make ResolveString return an atom

Almost all callers do xkb_atom_intern on the currently returned string,
while ResolveString converts the atom to the string to begin with...
uselss double work.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoatom: add xkb_atom_lookup
Ran Benita [Fri, 31 Aug 2012 15:52:26 +0000 (18:52 +0300)]
atom: add xkb_atom_lookup

This will only lookup the string and return the atom if found; it will
not intern it if not. This is useful when e.g. getting a string from the
user (which may be arbitrary) and comparing against atoms.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoatom: separate lookup logic from atom_intern
Ran Benita [Fri, 31 Aug 2012 15:47:28 +0000 (18:47 +0300)]
atom: separate lookup logic from atom_intern

This would allow us to add a non-interning xkb_atom_lookup function.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoatom: make type and name of the 'a' field clearer
Ran Benita [Fri, 31 Aug 2012 15:22:03 +0000 (18:22 +0300)]
atom: make type and name of the 'a' field clearer

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest/rules-file: add benchmark
Ran Benita [Tue, 28 Aug 2012 16:07:07 +0000 (19:07 +0300)]
test/rules-file: add benchmark

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest: add rmlvo-to-kccgst tool
Ran Benita [Wed, 29 Aug 2012 08:54:05 +0000 (11:54 +0300)]
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>
11 years agorules: fix check for appending '|' character when applying
Ran Benita [Wed, 29 Aug 2012 09:10:28 +0000 (12:10 +0300)]
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>
11 years agoUse XKB_MOD_INVALID instead of XkbNoModifier
Ran Benita [Wed, 29 Aug 2012 12:17:00 +0000 (15:17 +0300)]
Use XKB_MOD_INVALID instead of XkbNoModifier

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoDon't printf NULL strings
Ran Benita [Wed, 29 Aug 2012 07:12:56 +0000 (10:12 +0300)]
Don't printf NULL strings

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoxkbcomp: add debug messages of the RMLVO and KcCGST
Ran Benita [Wed, 29 Aug 2012 07:06:47 +0000 (10:06 +0300)]
xkbcomp: add debug messages of the RMLVO and KcCGST

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoinclude: document ParseIncludeMap better
Ran Benita [Tue, 28 Aug 2012 21:44:58 +0000 (00:44 +0300)]
include: document ParseIncludeMap better

The format of the include statment is not explained anywhere, the code
is confusing and the comments misleading. Try to explain it better.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest/data/symbols: keypad can only have one default section
Ran Benita [Tue, 28 Aug 2012 12:55:35 +0000 (15:55 +0300)]
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>
11 years agoinclude: properly use the default map if none is found
Ran Benita [Tue, 28 Aug 2012 12:05:01 +0000 (15:05 +0300)]
include: properly use the default map if none is found

For some reason this piece of code wasn't copied from xkbcomp, which
causes all of the warnings like these:
Warning:       No map in include statement, but "pc" contains several; Using first defined map, "pc105"

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoSet log level for tests through env, not directly
Ran Benita [Thu, 30 Aug 2012 17:23:35 +0000 (20:23 +0300)]
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>
11 years agolog: replace "priority" by "level" everywhere
Ran Benita [Mon, 27 Aug 2012 21:42:59 +0000 (00:42 +0300)]
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>
11 years agoaction: fix LookupEntry for "lockdevbtn"
Ran Benita [Mon, 3 Sep 2012 07:28:58 +0000 (10:28 +0300)]
action: fix LookupEntry for "lockdevbtn"

xkbcomp has that bug as well, guess no one uses it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoaction: remove redundant check
Ran Benita [Sun, 2 Sep 2012 13:33:02 +0000 (16:33 +0300)]
action: remove redundant check

The NoAction handler always errors out with the same message.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoaction: keep array of default actions, instead of list of changes
Ran Benita [Sun, 2 Sep 2012 08:29:31 +0000 (11:29 +0300)]
action: keep array of default actions, instead of list of changes

The implementation of changing the default properties of actions, e.g. a
statements such as (from test/data/compat/basic):
    setMods.clearLocks= True;
    latchMods.clearLocks= True;
    latchMods.latchToLock= True;
works by keeping a list of ActionInfo's, each containing the neccesary
info from each statement, and then when some action comes up (e.g. in an
interpret statment) it goes through the list, and applies the relevent
ActionInfo's to the newly-constructed xkb_action.

Instead of doing this, we add a struct ActionsInfo, which contains an
array of xkb_actions, one for each type. When a default changing
statement appears, we change the action in the array; when a new action
comes up, we just copy from the array. This is simpler to figure out,
and pretty straightforward.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoaction: disallow setting an action_field default for all types
Ran Benita [Sun, 2 Sep 2012 13:16:57 +0000 (16:16 +0300)]
action: disallow setting an action_field default for all types

Currently where it is possible to write:
    setMods.clearLocks = True;
It's also possible to write:
    action.clearLocks = True;
This will set the default value for the clearLocks action field for
*all* action types, as opposed to just setMods in this case. If
subsequently an action is used for which this field does not make sense,
it will error out.
This doesn't make any sense, because any given field is only possible by at
most 3 or 4 action types... which you might as well write explicitly and
avoid the side effect mentioned above.
Needless to say this is one of xkbcomp's "hidden features" and is not
used anywhere; remove it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoaction: clean up formatting of extern functions
Ran Benita [Sun, 2 Sep 2012 07:35:08 +0000 (10:35 +0300)]
action: clean up formatting of extern functions

Make it a bit easier to understand what they do.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: don't strdup a default name
Ran Benita [Fri, 31 Aug 2012 09:12:13 +0000 (12:12 +0300)]
types: don't strdup a default name

None of the other files does that.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: use darray for KeyTypesInfo instead of list
Ran Benita [Fri, 31 Aug 2012 09:06:50 +0000 (12:06 +0300)]
types: use darray for KeyTypesInfo instead of list

Simpler, uses less memory and more efficient.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: remove outdated comments
Ran Benita [Mon, 27 Aug 2012 20:00:07 +0000 (23:00 +0300)]
types: remove outdated comments

The code is pretty straightforward now...

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap: optimize FindInterpsForKey a bit
Ran Benita [Mon, 3 Sep 2012 07:23:44 +0000 (10:23 +0300)]
keymap: optimize FindInterpsForKey a bit

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap: refactor ApplyInterpsToKey
Ran Benita [Wed, 29 Aug 2012 21:12:41 +0000 (00:12 +0300)]
keymap: refactor ApplyInterpsToKey

There's really not much to explain what the function used to do there...

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoAdd xkbcomp/keymap.c and move some code there
Ran Benita [Wed, 29 Aug 2012 12:02:40 +0000 (15:02 +0300)]
Add xkbcomp/keymap.c and move some code there

Add CompileKeymap to do most of what compile_keymap_file does now, and
move UpdateKeymapFromModifiers along with it from (mostly unrelated)
compat.c.
Also rename UpdateKeymapFromModifiers to UpdateDerivedKeymapFields,
because it does more than update the modifiers.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoMove enum xkb_file_type to xkbcomp/ast.h
Ran Benita [Mon, 27 Aug 2012 16:20:41 +0000 (19:20 +0300)]
Move enum xkb_file_type to xkbcomp/ast.h

This is a more suitable place for this enum, since it's internal to
xkbcomp.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoxkbcomp: clean up compile_keymap function
Ran Benita [Mon, 27 Aug 2012 15:58:36 +0000 (18:58 +0300)]
xkbcomp: clean up compile_keymap function

We make the xkb_file_type enum sequential instead of masks, and then
we don't have to repeat the file types several times in the function.
Makes the code cleaner.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agomap, state: check for KeycodeInRange only in API functions
Ran Benita [Thu, 30 Aug 2012 09:14:29 +0000 (12:14 +0300)]
map, state: check for KeycodeInRange only in API functions

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: fix mod_names_are_active
Ran Benita [Thu, 30 Aug 2012 09:13:37 +0000 (12:13 +0300)]
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>
11 years agostate: fix type confusion within xkb_state_update_mask
Ran Benita [Thu, 30 Aug 2012 08:21:03 +0000 (11:21 +0300)]
state: fix type confusion within xkb_state_update_mask

idx should be xkb_mod_index_t, while mod is the mask.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: remove unneeded optimization
Ran Benita [Thu, 30 Aug 2012 14:15:39 +0000 (17:15 +0300)]
state: remove unneeded optimization

The code that follows does exactly that.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: light indicator when either condition is satisfied
Ran Benita [Mon, 27 Aug 2012 08:51:37 +0000 (11:51 +0300)]
state: light indicator when either condition is satisfied

For the indicator to be set, it is sufficient for at least one of the
group, modifier, or control state to match; this is in line with the
xkblib spec, section 8.2 and ComputeAutoState() in xserver/xkb/xkbLEDs.c
(though the xserver implementation differs from the spec on some
points...).

This also adds a tiny optimization to skip the entire check if the mask
is empty.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: fix led_update_all group mask calculation
Ran Benita [Mon, 27 Aug 2012 08:25:23 +0000 (11:25 +0300)]
state: fix led_update_all group mask calculation

The one above uses which_mods, this one should use which_groups.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: remove outdated comments
Ran Benita [Mon, 27 Aug 2012 20:05:04 +0000 (23:05 +0300)]
keycodes: remove outdated comments

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: use darray for aliases instead of list
Ran Benita [Fri, 31 Aug 2012 15:15:01 +0000 (18:15 +0300)]
keycodes: use darray for aliases instead of list

Uses slightly more memory, but worth it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: use array for indicator names instead of list
Ran Benita [Fri, 31 Aug 2012 08:40:35 +0000 (11:40 +0300)]
keycodes: use array for indicator names instead of list

Using a simple array here to mirror keymap->indicator_names makes much
more sense, and is simpler.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: ignore "virtual" in indicators
Ran Benita [Fri, 31 Aug 2012 08:13:24 +0000 (11:13 +0300)]
keycodes: ignore "virtual" in indicators

The distinction between real/virtual indicators is useless for us, we
can just ignore it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: call deinit functions Clear instead of Free
Ran Benita [Tue, 28 Aug 2012 11:45:03 +0000 (14:45 +0300)]
symbols: call deinit functions Clear instead of Free

Everywhere else Free is reserved for when the argument is free'd as
well.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: remove comparison of unsigned >= 0
Ran Benita [Mon, 27 Aug 2012 06:37:01 +0000 (09:37 +0300)]
symbols: remove comparison of unsigned >= 0

clang warning.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agovmod: remove outdated comments
Ran Benita [Thu, 30 Aug 2012 10:49:23 +0000 (13:49 +0300)]
vmod: remove outdated comments

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agovmod: ClearVModInfo doesn't need the keymap
Ran Benita [Tue, 28 Aug 2012 08:14:54 +0000 (11:14 +0300)]
vmod: ClearVModInfo doesn't need the keymap

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agovmod: remove useless keymap initialization
Ran Benita [Tue, 28 Aug 2012 08:11:40 +0000 (11:11 +0300)]
vmod: remove useless keymap initialization

keymap->vmods is not touched until UpdateModifiersFromCompat,
where it initialized and used.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agovmod: remove support for resolving integer to virtual modifier
Ran Benita [Wed, 15 Aug 2012 19:07:37 +0000 (22:07 +0300)]
vmod: remove support for resolving integer to virtual modifier

This is only relevant to the virtualModifier= statement in interpret
statements in xkb_compat. The current code allows to write e.g.
    virtualModifier = 4
to get the virtual modifier whose index happens to be 4 (possibly
declared in other files or sections, i.e. xkb_types). Doing this is
undeterministic, will break without notice, and not used anywhere.
Don't allow it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: move op_type/value_type_to_string functions to ast
Ran Benita [Wed, 15 Aug 2012 18:45:02 +0000 (21:45 +0300)]
expr: move op_type/value_type_to_string functions to ast

Generally the enum-to-string function should appear where the enum is
defined.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agovmod: remove support for direct vmod -> real mod mapping
Ran Benita [Tue, 14 Aug 2012 14:11:16 +0000 (17:11 +0300)]
vmod: remove support for direct vmod -> real mod mapping

The current code supports statements such as:
    virtual_modifiers NumLock = Mod2;
This would set the mapping from the NumLock vmod to the Mod2 real mod
directly, without going through the virtualModifier field in an
interpret statement (in xkb_compat) or vmods field in a key statement
(in xkb_symbols).

This is undocumented, unused and complicates things, so remove it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoxkbcomp: seperate keymap-copying code from Compile functions
Ran Benita [Wed, 15 Aug 2012 07:10:44 +0000 (10:10 +0300)]
xkbcomp: seperate keymap-copying code from Compile functions

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: only compute 'bool report' once
Ran Benita [Sun, 2 Sep 2012 16:16:34 +0000 (19:16 +0300)]
compat: only compute 'bool report' once

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: disallow changing global defaults from within an interpret
Ran Benita [Sun, 2 Sep 2012 08:49:43 +0000 (11:49 +0300)]
compat: disallow changing global defaults from within an interpret

It's currently possible to write something like this:
    interpret Num_Lock+Any {
        virtualModifier = NumLock;
        action = LockMods(modifiers=NumLock);
        !indicator.allowExplicit;
    };
The final statement has the same effect as writing it in the global file
scope, which changes the default indicator (which all subsequent
indicators start off as). This very strange and also unused; if someone
does it he probably expects it to affect only the local scope, and he
might then get unexpected behavior. So don't allow it.

Also, HandleInterpVar is clearly a misnomer (as it can also change
indicator defaults) so rename it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: use darray instead of list for interps
Ran Benita [Mon, 27 Aug 2012 19:06:50 +0000 (22:06 +0300)]
compat: use darray instead of list for interps

No need for a list here.

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