Commit Graph

876 Commits (b04d896ab25cca055e5bcc3d2e58d9c9fb6ef3c4)

Author SHA1 Message Date
Daniel Stone b04d896ab2 kbproto unentanglement: XkbNumVirtualMods
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-10 19:23:35 +01:00
Daniel Stone 74ec4c1c3f kbproto unentanglement: XkbNumIndicators
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-10 19:23:35 +01:00
Daniel Stone 4b8ceae91f kbproto untanglement: XkbKbdNumGroups
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-10 19:23:35 +01:00
Daniel Stone f5dffd2b6e 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>
2012-09-10 18:26:20 +01:00
Ran Benita 3b6b214c78 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>
2012-09-05 16:37:43 +03:00
Ran Benita 0071227e7f 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>
2012-09-05 16:37:02 +03:00
Ran Benita 54d1d5ed5a 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>
2012-09-05 13:47:46 +03:00
Ran Benita 5f613988c8 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>
2012-09-04 17:20:46 +03:00
Ran Benita af2a8b3a37 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>
2012-09-03 10:31:13 +03:00
Ran Benita 7ae0c6bac4 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>
2012-09-03 10:31:13 +03:00
Ran Benita 1a9968839e 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>
2012-09-03 10:31:13 +03:00
Ran Benita 7aa31097bf 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>
2012-09-03 10:31:13 +03:00
Ran Benita 651e1dab04 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>
2012-09-03 10:31:13 +03:00
Ran Benita f205d0f9b6 atom: make type and name of the 'a' field clearer
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:13 +03:00
Ran Benita 1aa6e2b1e2 test/rules-file: add benchmark
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:13 +03:00
Ran Benita 480f919d77 test: add rmlvo-to-kccgst tool
For a quick look at what components result from the rules.

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

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

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita 41472822b6 Use XKB_MOD_INVALID instead of XkbNoModifier
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita 300f3fb1e0 Don't printf NULL strings
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita bce90d5b2c xkbcomp: add debug messages of the RMLVO and KcCGST
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita 8e6fce9b22 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>
2012-09-03 10:31:12 +03:00
Ran Benita 2a026f6f72 test/data/symbols: keypad can only have one default section
Avoids a warning, from xkeyboard-config:

commit 6676053f2c93596c2aaa9905151a5c76355a1540
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Jun 29 09:53:45 2012 +1000

    symbols: keypad can only have one default section

    Warning:          Multiple default components in keypad
                      Using x11, ignoring pointerkeys

    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita 799cc064d3 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>
2012-09-03 10:31:12 +03:00
Ran Benita f3c4032f35 Set log level for tests through env, not directly
This way the test logs have all the information, but we don't get eye
bleed every time we run them manually. One can always use
TESTS_ENVIRONMENT (we correctly use AM_TESTS_ENVIRONMENT now), or set
the envvars from the shell.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita 8d7d9792d1 log: replace "priority" by "level" everywhere
Now that we don't use syslog, "level" does sound more commonplace. We
should change it while there is still nobody using it.
Also leave some space between the integers of the xkb_log_level enum
values, if we ever need to shove more in between.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita 95d4fb9e4b action: fix LookupEntry for "lockdevbtn"
xkbcomp has that bug as well, guess no one uses it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita 7e0c49e084 action: remove redundant check
The NoAction handler always errors out with the same message.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:20 +03:00
Ran Benita 87bfd97333 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>
2012-09-03 10:25:20 +03:00
Ran Benita 4ca85c7b3b 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>
2012-09-03 10:25:20 +03:00
Ran Benita ba9f66bda3 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>
2012-09-03 10:25:20 +03:00
Ran Benita 1736e7daad types: don't strdup a default name
None of the other files does that.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:20 +03:00
Ran Benita 149e1b2f0d types: use darray for KeyTypesInfo instead of list
Simpler, uses less memory and more efficient.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:19 +03:00
Ran Benita 8654d36e7a types: remove outdated comments
The code is pretty straightforward now...

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:19 +03:00
Ran Benita db639be6df keymap: optimize FindInterpsForKey a bit
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:19 +03:00
Ran Benita 872e15e52c 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>
2012-09-03 10:13:42 +03:00
Ran Benita 8c1b1b0e9e 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>
2012-09-02 19:17:09 +03:00
Ran Benita 591df1156d 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>
2012-09-02 19:17:09 +03:00
Ran Benita efc2d74141 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>
2012-09-02 19:17:09 +03:00
Ran Benita 82491d5fd1 map, state: check for KeycodeInRange only in API functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 06d7803a6d state: fix mod_names_are_active
This function was always returning -1.
Adding a test, we see that test/state.c treat the is_active functions as
returning booleans, which would treat -1 as success, so we test for > 0
instead (most users would probably get this wrong as well...).
Also update the documentation for the are_active functions, and add a
ATTR_NULL_SENTINEL for gcc __attribute__((sentinel)).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 9f0c016063 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>
2012-09-02 19:17:09 +03:00
Ran Benita ae576e85b7 state: remove unneeded optimization
The code that follows does exactly that.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita a45b7d7559 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>
2012-09-02 19:17:09 +03:00
Ran Benita d1b476a387 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>
2012-09-02 19:17:09 +03:00
Ran Benita 9ba5ac0ec0 keycodes: remove outdated comments
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita bebad402e4 keycodes: use darray for aliases instead of list
Uses slightly more memory, but worth it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 518aff6d7b 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>
2012-09-02 19:17:09 +03:00
Ran Benita be78b8264d 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>
2012-09-02 19:17:09 +03:00
Ran Benita 4c56d4d9c0 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>
2012-09-02 19:17:09 +03:00
Ran Benita 2eba51c0f6 symbols: remove comparison of unsigned >= 0
clang warning.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00