Commit Graph

983 Commits (1651e5af465f45f9b6fff7e65ab958425ccda00b)

Author SHA1 Message Date
Ran Benita 7261f404d2 state, context: allow passing NULL to *_unref()
For error handling code, it's nice to be able to pass NULL to these
function without worrying about segfaults ensuing. free() sets the
precedent here.

Also document this fact.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-29 01:20:04 +02:00
Ran Benita a51ee70419 state: don't use xkb_keymap_num_layouts internally
Clearer and more greppable this way.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-26 16:34:39 +02:00
Ran Benita ee6f3f2809 state: don't use xkb_state_serialize_* internally
The code in these cases is clearer when done directly.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-26 16:12:28 +02:00
Ran Benita 6f093ad56b state: fix possible index-out-of-bounds in action dispatch table
The current code assumes that action->type always falls in the range of
the xkb_action_type enum. But keymaps can also have Private actions,
which are allowed to set their own type number.

So with a default xkeyboard-config keymap, keycode 86 at level 4, which
triggers such an action, causes us to crash.

Fix it by always checking the bounds.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-24 23:09:26 +02:00
Ran Benita f76859bc87 keymap: use plain array for keymap->group_names
Again it is not resized.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-23 17:22:13 +02:00
Ran Benita 867992cd21 state: fix typo in state component copying
Gladly no-one should have been fast enough to hit this.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-23 17:22:13 +02:00
Ran Benita 4b81c9f3e3 Report which components of the state have changed
We add a return value to the xkb_state_update_key and
xkb_state_update_mask, which reports to the caller which of the state
components have changed as a result.

This restores the XKB functionality of the XkbStateNotify and
XkbIndicatorsStateNotify events. See:
http://www.x.org/releases/current/doc/kbproto/xkbproto.html#Events
It is quite useful in some situations. For example, it allows an
application to avoid doing some work if nothing of relevance in the
state has changed. Say, a keyboard layout applet. Also useful for
debugging.

The deltas themselves are not provided, because I can't see a use case.
If needed, it should be possible to add some API for that.

In xkbcommon, keymaps are immutable, so all of the other *Notify events
from XKB are irrelevant.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-22 21:58:03 +02:00
Ran Benita 550cb24d3c state: add struct state_components
This holds all of the state component fields in the state in one struct.
We will later want to keep the previous state components after updates,
so this will allow us to do it without duplicating the fields.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-22 21:55:43 +02:00
Ran Benita 6a94b122a4 Split the mods, layout, leds parts of xkb_state_components
Note first:
This commits breaks the ABI somewhat. If an application is run against
this commit without recompiling against the updated header, these break:
    - xkb_state_layout_*_is_active always retuns false.
    - xkb_state_serialize_mods always returns 0.
So it might break layout switching in some applications. However,
xkbcommon-compat.h provides the necessary fixes, so recompiling should
work (though updating the application is even better).

Split the enum to its individual components, which enables us to refer
to them individually. We will use that later for reporting which
components of the state have changed after update.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-22 21:48:40 +02:00
Ran Benita 0779d9dcad Silence a couple of warnings
These appear to come and go randomly.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-21 17:13:25 +02:00
Ran Benita bb82759c90 Move _text() functions from keymap-dump to text.c
And make them use context_get_buffer() instead of using a static char
array.

This was the last non-thread-safe piece we had, as far as I can tell.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-18 23:12:24 +02:00
Ran Benita e6946ae2c5 Remove a couple more uses of static char buffers
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-18 22:55:17 +02:00
Ran Benita 714e95e144 Contextualize GetBuffer()
Instead storing the buffer in a non-thread-safe static array, we move it
to the context.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-18 22:51:10 +02:00
Ran Benita eb748ab643 Clean up xkb_sym_interpret a bit
First we split the LEVEL_ONE_ONLY bit off of the 'match' field, which
allows us to turn enum xkb_match_operation to a simple enum and remove
the need for MATCH_OP_MASK.

Next we rename 'act' to 'action', because we've settled on that
everywhere else.

Finally, SIMatchText is changed to not handle illegal values - it
shouldn't get any. This removes one usage of the GetBuffer hack.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-18 21:04:27 +02:00
Ran Benita 5d9a5cb003 Commit and distribute ks_tables.h
The ks_tables.h file is generated by makekeys.py from
xkbcommon-keysyms.h, which in turn is generated initially by 'make
update-keysyms'. The xkbcommon-keysyms.h file is commited to git and
distributed in the tarball. Since ks_tables.h should only ever change
when xkbcommon-keysyms.h changes, it is more sensible to update them
together and treat them the same, instead of generating ks_tables.h
every time for every builder with 'make', as we do now.

This means we don't need python as a build dependency (only the one
running update-keysyms, i.e. no one, needs this), and we can be
sure exactly the same file is used by everyone. We also don't need to
run makekeys.py on every build.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-17 20:09:09 +02:00
Ran Benita 179855116d utils: add and use ARRAY_SIZE macro
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-16 21:31:25 +02:00
David Herrmann 7b3bd11f92 Add xkb_keysym_from_name() flags argument for case-insensitive search
This adds a flags argument to xkb_keysym_from_name() so we can perform a
case-insensitive search. This should really be supported as many keysyms
have really weird capitalization-rules.

However, as this may produce conflicts, users must be warned to only use
this for fallback paths or error-recovery. This is also the reason why the
internal XKB parsers still use the case-sensitive search.

This also adds some test-cases so the expected results are really
produced. The binary-size does _not_ change with this patch. However,
case-sensitive search may be slightly slower with this patch. But this is
barely measurable.

[ran: use bool instead of int for icase, add a recommendation to the
doc, and test a couple "thorny" cases.]

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-16 21:29:09 +02:00
Ran Benita 5fff637e07 makekeys: replace helper with python script and binary search
This removes the complicated and undocumented hash-table creation-helper
and replaces it with an autogenerated sorted array. The search uses simple
bsearch() now.

We also tried using gperf but it turned out to generate way to big
hashtables and when reducing the size it isn't really faster than
bsearch() anymore.

There are no users complaining about the speed of keysym lookups and we
have no benchmarks that tell that we are horribly slow. Hence, we can
safely use the simpler approach and drop all that old code.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-16 21:10:04 +02:00
Ran Benita 3477d9e448 Finish first round of API documentation
There are a few @todo's, but nothing serious.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-13 14:03:29 +02:00
Ran Benita f43b33c02f state: make mod_index_is_consumed() return -1 on invalid input
Like all the other functions.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-13 13:13:55 +02:00
Ran Benita 523e46f41a Change log env vars to XKB_LOG_LEVEL/VERBOSITY
A bit more consistent and descriptive.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-12 10:17:57 +02:00
Ran Benita 89523789ca ast: simplify AppendStmt
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 21:51:08 +02:00
Ran Benita bbf388ec1f Make xkb_keymap_num_leds return the index range instead of active count
Currently xkb_keymap_num_leds() returns a count of valid (settable)
leds. Because the indexes might be non-consecutive, and some leds
might not be settable, it is incorrect to use this function for
iterating over the leds in the keymap. But this is the main use case of
this function, so instead of the current behavior we adapt the function
to the use case by making it return the needed range of iteration.
The caller needs to handle invalid intermittent indexes, though.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 16:54:17 +02:00
Ran Benita b6ddd10568 keymap: rename keymap->sym_interpret -> sym_interprets
This can be a bit confusing.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 14:05:49 +02:00
Ran Benita e43f53a698 compat: add documentation for interpret's
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 14:03:03 +02:00
Ran Benita 90b1984cba compat: don't forget to copy XKB_MATCH_NONE interpret's
Commit a8d462e366 accidentally removed the
OR with XKB_MATCH_NONE. It is in fact unused though.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 12:10:26 +02:00
Ran Benita 9197eb0fb3 Remove the XKB_NUM_INDICATORS limit
Use a darray instead of a static array of size 32.
We still enforce XKB_MAX_LEDS because of the size of xkb_led_mask_t.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 19:44:23 +02:00
Ran Benita f3732d8349 keymap: don't use darray for keymap->keys
It's never resized.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 17:51:06 +02:00
Ran Benita bdea377c93 Rename XKB_NUM_GROUPS to XKB_MAX_GROUPS
This is a more appropriate name now.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 17:30:15 +02:00
Ran Benita 1dbb2c4a9a keycodes: refactor AddIndicatorName
Make it shorter and fix the XXX.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 12:25:23 +02:00
Ran Benita 2f4db8a95b keymap, state: don't assume led index < xkb_keymap_num_leds
xkb_keymap_num_leds() returns the number of leds that have any
possibility of being set. Even if a led is defined but can not be set in
any way, it is not counted.

In a few places currently we assume that led indexes are smaller than
this number, which is wrong both for the above reason and for the fact
that the xkb format actually allows explicitly setting the indicator
index, which means that the indexes might be non-consecutive.

We don't really have good API to iterate on leds, now, because
xkb_keymap_num_leds is pretty useless. To work around that we use
sizeof(xkb_led_mask_t) * 8.

This makes the "Group 2" led work (try switching to a layout other than
the first in test/interactive).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 10:10:45 +02:00
Ran Benita 9179fed76b keysym: fix xkb_keysym_is_upper/lower() to work properly
Our current code (taken from the xserver) doesn't handle unicode keysyms
at all, and there seem to be some other changes compared to libX11,
which is what xkbcomp uses. So we just copy the code that does that from
libX11.
It would be much better to not have to hardcode unicode tables like
that, but it's probably better than dealing with glibc locale stuff for
now. It also doesn't affect our binary size much.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-09 21:39:16 +02:00
Ran Benita 2ac319c54a compat: fix bad interpret predicate mods "all" calculation
Commit 9984d1d03c changed the type of
interpret->mods to xkb_mod_mask_t, but this bit of code assumes that the
type is uint8_t.
This code is not usually run (for example by our tests), but when it
does keymap-dump would print out all of the modifiers (including the
virtual ones) which causes recompilation of the output to fail
miserably.

https://bugs.freedesktop.org/show_bug.cgi?id=55769

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-09 10:36:48 +11:00
Ran Benita 9984d1d03c keymap: use xkb_mod_mask_t for interpret->mods and modmap
These are both real modifier masks, but we keep this information only in
the program logic now so when we change it we don't have to worry about
the type.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:42:42 +02:00
Ran Benita fcceeeafa8 symbols: refactor AddModMapEntry
It really asks for it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:42:00 +02:00
Ran Benita 6d74e66e3f Replace 0xff with MOD_REAL_MASK_ALL
To make it easier to see where it's used. The name is just to match
MOD_REAL.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:42:00 +02:00
Ran Benita a1124b5991 expr: unify the real and virtual modifier functions
This again pushes the mod type annotation to the original call site, to
make it easier to grep to see where the real/virtual distinction
matters.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:42:00 +02:00
Ran Benita 39232e6dae Remove now-unneeded mod type annotations
Most of the mod type annotations can now be changed to MOD_BOTH, because
if you pass a mask which can only contain real mods in the first place to
e.g. ModMaskText, then MOD_REAL and MOD_BOTH will give the same result.

In the cases where MOD_BOTH is only ever the argument, we just remove
it. What's left is where it really "matters".

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:42:00 +02:00
Ran Benita e6e3bda393 expr: share code for modifier functions
We can make more use of the functions in text.c now and remove some
cruft.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:42:00 +02:00
Ran Benita 9ebd2f67f4 text: explicitly take mod_type in mod functions
This essentially "tags" each invocation of the functions with the
modifier type of the argument, which allows for easy grepping for them
(with the aim being, to remove anything but MOD_BOTH).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:59 +02:00
Ran Benita 6d580127d8 text: share code for modifiers
Add static common functions which take enum mod_type, and change the
existing ones to use them.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:59 +02:00
Ran Benita 424de613af Keep real and virtual mods in the same table in the keymap
We change the keymap->vmods array into keymap->mods, and change it's
member type from struct xkb_vmod to struct xkb_mod. This table now
includes the real modifiers in the first 8 places. To distinguish
between them, we add an enum mod_type to struct xkb_mod.

Besides being a more reasonable approach, this enables us to share
some code later, remove XKB_NUM_CORE_MODS (though the 0xff mask still
appears in a few places), and prepares us to flat out remove the
distinction in the future. This commit just does the conversion.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:59 +02:00
Ran Benita 1005b320f1 Don't use shifted virtual modifier masks
Modifier masks can be confusing in some places. For example,
key->vmodmap only contains virtual modifiers, where the first is in
position 0, the second in 1 etc., while normally in a xkb_mod_mask_t the
virtual modifiers start from the 8th (XKB_NUM_CORE_MODS) position. This
happens in some other places as well.

Change all of the masks to be in the usual real+virtual format, and when
we need to access e.g. keymap->vmods we just adjust by
XKB_NUM_CORE_MODS. (This also goes for indexes, e.g.
interpret->virtual_modifier).

This makes this stuff easier to reason about.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:59 +02:00
Ran Benita 6974e1f9ac expr: don't expose LookupModIndex
The Lookup* functions should remain a private implementation detail of
the expr.c file.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:59 +02:00
Ran Benita aed3140e8d Remove VModInfo for now
VModInfo currently is only used to track which virtual modifiers were
declared in the file which owns the VModInfo. This, in turn, is only
used in ResolveVirtualModifier, which in turn is only used to resolve
the virtualModifier field in an interpret statement (compat.c). In other
words, it is used to ensure that interprets can only use a vmod which
was declared in the same map.

We remove this now, because it doesn't do much and distracts from other
changes; we will later re-add it properly. Specificly, we will make it
so that virtual modifiers are not the exception in that they modify the
keymap directly, instead of keeping the changes in some *Info struct and
commiting them to the keymap at the end of the compilation. (This is bad
because if a vmod is added to the keymap, and then the compilation of
this specific file fails, the change sticks around nonetheless).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:59 +02:00
Ran Benita 9a2ce2a5ad vmod: don't allow to add a vmod with the name of a real mod
Otherwise strange thing might ensue.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:59 +02:00
Ran Benita b65980ccff state: don't needlessly fetch the xkb_key
It's a leftover.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:59 +02:00
Ran Benita 1f4009d4e9 vmod: remove merge argument from HandleVModDef
It's unused and unneeded.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:59 +02:00
Ran Benita a75989b96e Omit struct '_Name' from non-recursive struct typedefs
Just a pet peeve.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:58 +02:00
Ran Benita 1401b0fb5e expr: don't allow "none" in LookupModIndex
LookupModMask handles this before calling LookupModIndex, and the only
other user in symbols.c doesn't handle this return value at all.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:58 +02:00
Ran Benita 239a5be10e keysym-utf: make keysym->unicode table a bit smaller
Saves a few kbytes, and unlikely to change.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:58 +02:00
Ran Benita dd29b14e11 Remove the XKB_NUM_VIRTUAL_MODIFIERS limit
Turn the virtual modifiers arrays in the keymap to a single darray,
which doesn't use this limit. The number of virtual modifiers is still
limited by the size of xkb_mod_mask_t, so we make sure not to go over
that.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:58 +02:00
Ran Benita 8016c6f4f1 state: simplify xkb_state_mod_index_is_active
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:58 +02:00
Ran Benita e5b6055b34 state: don't ignore type argument in xkb_state_mod_*_are_active
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:58 +02:00
Ran Benita 1a6b1e0788 state: fix bad EFFECTIVE check in *_is_active()
This is a regression introduced in ed78fbcb30.
XKB_STATE_EFFECTIVE is just a OR of the other states, so using & here is
completely wrong. So test/state shows for example:
    dumping state for LCtrl down:
            group English (US) (0): effective depressed latched locked
            mod Control (2): depressed latched locked
    dumping state for LCtrl + RAlt down:
            group English (US) (0): effective depressed latched locked
            mod Control (2): depressed latched locked
            mod Mod1 (3): depressed latched locked
    dumping state for RAlt down:
            group English (US) (0): effective depressed latched locked
            mod Mod1 (3): depressed latched locked
    dumping state for Caps Lock:
            group English (US) (0): effective depressed latched locked
            mod Lock (1): depressed latched locked
            led Caps Lock (0): active
    dumping state for Alt-Shift-+
            group English (US) (0): effective depressed latched locked
            mod Shift (0): depressed latched locked
            mod Mod1 (3): depressed latched locked
which is bogus.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:58 +02:00
Ran Benita fe1faa143e Use our types instead of int/uint32_t in a few places
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06 21:41:58 +02:00
Ran Benita 1c88088766 Don't scan and parse useless maps
One physical xkb file may (and usually does) contain multiple maps. For
example, the us symbols file contains a map for every variant.
Currently, when we need a map from a file (specific or default), we
parse the entire file into a list of XkbFile's, find the map we want and
discard the others. This happens for every include statement. This is a lot
of unnecessary work; this commit is a first step at making it better.

What we do now is make yyparse return one map at a time; if we find what
we want, we can stop looking and avoid processing the rest of the file.

This moves some logic from include.c to parser.y (i.e. finding the
correct map, named or default). It also necessarily removes the
CheckDefaultMap check, which warned about a file which contains multiple
default maps. We can live without it.

Some stats with test/rulecomp (under valgrind and the benchmark):

Before:
==2280==   total heap usage: 288,665 allocs, 288,665 frees, 13,121,349 bytes allocated
compiled 1000 keymaps in 10.849487353s

After:
==1070==   total heap usage: 100,197 allocs, 100,197 frees, 9,329,900 bytes allocated
compiled 1000 keymaps in 5.258960549s

Pretty good.

Note: we still do some unnecessary work, by parsing and discarding the
maps before the one we want. However dealing with this is more
complicated (maybe using bison's push-parser and sniffing the token
stream). Probably not worth it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 15:26:00 +02:00
Ran Benita 26e685daae scanner: don't strdup the file name
We don't modify it and there's no way to modify the original in the
scanner_extra life time.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 15:25:56 +02:00
Ran Benita ee4ab30ea2 scanner: share code in XkbParse{File,String}
Some refactoring to prepare for changes in the parse() function.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 15:25:25 +02:00
Ran Benita 471ebad623 scanner: remove uselss 'last symbol' error message
It never shows something useful. Besides, you already get the line
number, which is enough.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 14:29:49 +02:00
Ran Benita 22684cd1dd parser: remove XkbCompMapList rule
This rule allows you to put several xkb_keymaps in one file.
This doesn't make any sense: only the default/first can ever be used,
yet the others are fully parsed as well.
Different keymaps should just be put in different files.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 14:20:16 +02:00
Ran Benita 3b5ada233b parser: remove XkbConfig rule
This rule allows you to write file maps as:
    xkb_keycodes
    <BLA> = 5;
    [...]
instead of the usual format which is:
    xkb_keycodes {
        <BLA> = 5;
        [...]
    };

This is not documented, It is also not used in xkeyboard-config, and I
have never run into it otherwise. It also only allows one map per file.

It *might* be used in some obscure place, but probably nothing we should
care about; the simplified grammar is more useful for us now.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 14:20:16 +02:00
Ran Benita 26cc2f400a Don't use %z printf format
Some libc's don't support it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 14:20:16 +02:00
Ran Benita ed1203dfef rules: always initialize idx variable
gcc didn't catch this one.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30 12:44:52 +02:00
Ran Benita 32c19f4b44 keymap-dump: make it look better with long key names
Not worth messing around with too much, just make it legible.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27 21:31:33 +02:00
Ran Benita 41a7fed3f8 Fix type of keycode in parser and ast
For some reason keycodes were listed under mapFlags in the yylval union.
Fix it and some sanity checks.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27 21:12:08 +02:00
Ran Benita 3b389b15bf Don't limit key names to 4 characters
Currently you can't give a key in xkb_keycodes a name of more than
XKB_KEY_NAME_LENGTH (= 4) chars. This is a pretty annoying and arbitrary
limitation; it leads to names such as <RTSH>, <COMP>, <PRSC>, <KPAD>
etc. which may be hard to decipher, and makes it impossible to give
more standard names (e.g. from linux/input.h) to keycodes.

The purpose of this, as far as I can tell, was to save memory and to
allow encoding a key name directly to a 32 bit value (unsigned long it
was).

We remove this limitation by just storing the names as atoms; this lifts
the limit, allows for easy comparison like the unsigned long thing, and
doesn't use more memory than previous solution. It also relieves us from
doing all of the annoying conversions to/from long.

This has a large diffstat only because KeyNameText, which is used a lot,
now needs to take the context in order to resolve the atom.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27 21:12:08 +02:00
Ran Benita 53cfe8c362 xkbcomp/keymap: use default interpret in ApplyInterpsToKey
This makes the code easier to follow and does more explicitly what the
xkblib spec says:
     If no matching symbol interpretation is found, the server uses a
     default interpretation where:
        sym =	0
        flags =	XkbSI_AutoRepeat
        match =	XkbSI_AnyOfOrNone
        mods =	0
        virtual_mod =	XkbNoModifier
        act =	SA_NoAction

If a level doesn't have any keysyms, we don't apply anything to it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27 21:12:08 +02:00
Ran Benita 11df063265 state: add missing const in get_one_sym
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27 21:12:08 +02:00
Daniel Stone 5aaf65b74e Add xkb_state_key_get_one_sym
The trivial wrapper around xkb_state_key_get_syms that every user to
date has implemented.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-27 23:27:49 +10:00
Daniel Stone 29a8b1ceac Fix size_t vs. %d warning
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-26 10:28:52 +10:00
Ran Benita cfa6d25cb5 symbols: get rid of autoType
The autoType variable is supposed to tell us whether the type was
explicitly specified by the user or was detected automatically according
to the keysyms. It then allows us to know whether to prints the type
when we dump the keymap to a string or not.

Right now it is not always set when we find an automatic type, according
to some apparently legacy rules. We change it to simply this: type
computed automatically? -> don't print.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-25 11:49:23 +02:00
Ran Benita 76478418bc symbols: separate type-finding logic from CopySymbolsDef
It's easier to follow this in isolation. Besides, previously the error
reporting wasn't done very well.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-25 11:35:59 +02:00
Ran Benita 5d2659267a keymap: remove some more unneeded macros
It clearer to just access the needed data directly.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 14:57:30 +02:00
Ran Benita c955f8e2f9 keymap: store a pointer to the type in xkb_group instead of index
Gets rid of some more unneeded indirection, including the XkbKeyType
macro.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 14:41:09 +02:00
Ran Benita 01b00d7540 keymap, symbols: improve xkb_key memory layout
Add struct xkb_group and xkb_level for use in xkb_key, to mirror how
it's done in KeyInfo, GroupInfo, LevelInfo in symbols.c. This
corresponds more nicely to the logical data layout (i.e. a key has
groups which have levels), and also removes a lot of copying and ugly
code due to the index indirections and separate arrays which were used
before.

This uses more memory in some places (e.g. we alloc an action for every
level even if the key doesn't have any) but less in other places (e.g.
we no longer have to pad each group to ->width levels). The numbers say
we use less overall.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 12:46:51 +02:00
Ran Benita e44cd2e93b symbols: move keysyms into LevelInfo
Instead of maintaining a syms array in the GroupInfo + sym_index's in
the levels. This simplifies the code somewhat.
In order not to alloc for every level instead of every group, we only do
it if the level has more than one keysym (with a union). Since for now
this is a special case, it actually works out better memory-wise.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 12:33:06 +02:00
Ran Benita eaf9515229 symbols: fix index-out-of-bounds in FindAutomaticType
If we enter this branch, we have 3 <= width <= 4, so if the width is 3
than syms[3] is out of bounds.

Happily inherited from xkbcomp.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 10:19:02 +02:00
Ran Benita 504853de3b symbols: remove unneeded optimization
The levels will be resized to the number of levels of the type anyway,
so removing useless levels from the end here is unneeded.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:14:35 +02:00
Ran Benita e0573c766d keymap: use our type for keymap->enabled_ctrls
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 08:24:29 +02:00
Daniel Stone a8b6b08afb Add missing declaration for _xkbcommon_parse (aka yyparse)
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-24 14:36:46 +10:00
Ran Benita 1d47cbfc4a keymap.h: add note on why XKB_NUM_GROUPS is still there
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:13:32 +10:00
Ran Benita d941bc0c03 keymap, symbols: use darray for num_groups
Instead of using a static array of size XKB_NUM_GROUPS, because we want
to get rid of this limit.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:13:32 +10:00
Ran Benita 79bbf6f758 symbols: avoid possible access-out-of-bound due to explicit_group
The code that handles group name statements currently does this:
    info->group_names[grp - 1 + info->explicit_group] = name;
Other than the fact that this addition makes no sense, it actually can
reach out of the bounds of the array (which is of size XKB_NUM_GROUPS)
in the (non-realistic) case where (grp - 1) is not 0 (i.e. the statement
is not name[Group1] = "foo").

We also change explicit_group to be XKB_LAYOUT_INVALID if not set
otherwise, instead of initializing it to 0; this is clearer and if
someone happens to write 'us:1' for some reason, it will discard the
other groups in the file as it should.

This entire explicit_group thing was clearly bolted on as an
afterthought.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:13:32 +10:00
Ran Benita 6d97d0ce5e symbols: rename SymbolsInfo groupNames to group_names
Just to match the matching field in the keymap.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:13:32 +10:00
Ran Benita 7a90f9e225 keymap: don't use XKB_NUM_GROUPS for key->kt_index
One unneeded XKB_NUM_GROUPS less.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:13:32 +10:00
Ran Benita 9a18b87251 Add format argument to xkb_keymap_get_as_string
This function really needs a format argument, for symmetry with the
keymap creation functions. If we add new formats, we will almost
certainly want to add support for serializing it into a string. It would
also allow to convert from one format to another, etc.

The in the common case, the user would just want to use the format she
used to create the keymap; for that we add a special
XKB_KEYMAP_USE_ORIGINAL_FORMAT value, which will do that (it is defined
to -1 outside of the enum because I have a feeling we might want to use
0 for something else). To support this we need to keep the format inside
the keymap. While we're at it we also initialize keymap flags properly.

This changes the API, but the old xkb_map_get_as_string name works as
expected so this is the best time to do this.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:13:32 +10:00
Ran Benita 5d31b9e3e7 Add return value the xkb_keysym_get_name
This is useful to see whether the function was successful and whether
truncation occurred.
It just changes void -> int so shouldn't break API or ABI.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:13:32 +10:00
Ran Benita 0dd40125c5 API: add _context prefix to log-related functions
This is to follow the general scheme set by all of the other API
functions.
Since no one is using these functions yet, we don't (actually better
not) add the old names to xkbcommon-compat.h.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:54 +10:00
Ran Benita be3cbc993e keymap: remove XkbKeyGetKeycode
Because we keep the keycode inside the xkb_key now.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:54 +10:00
Ran Benita 428c6f313f symbols: convert KeyInfo->groups to darray
Before it was a static array of size XKB_NUM_GROUPS.

The previous cleanups made this transition a bit easier. This is a
first step for removing the XKB_NUM_GROUPS hardcoded limit; but for now
we still check that the groups are < XKB_NUM_GROUPS (e.g. in
ResolveGroup and GetGroupIndex) until the keymap, etc. is worked out as
well.

This also makes us alloc quite a bit less (this is just rulescomp):
Before:
==51999==   total heap usage: 291,474 allocs, 291,474 frees, 21,458,334 bytes allocated
After:
==31394==   total heap usage: 293,595 allocs, 293,595 frees, 18,150,110 bytes allocated
This is because most rmlvo's don't use the full 4 layouts that KeyInfo
had always alloced statically before.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:54 +10:00
Ran Benita f671ce07ff symbols: fix memleak from default KeyInfo
If the default KeyInfo gets any keysyms or actions, it needs to be
free'd.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:54 +10:00
Ran Benita a12b5f6224 symbols: disallow changing global defaults from within a key statement
Pretty much like e5fdbcbb99, again it isn't used.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:54 +10:00
Ran Benita b70abcaf36 symbols: fold PrepareKeyDef into CopySymbolsDef
The function is big enough already but it's nicer to read sequentially.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:54 +10:00
Ran Benita 419a497554 state: missing XKB_EXPORT on xkb_state_key_get_level
And some error handling.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:54 +10:00
Ran Benita 67b03cea0b state: correctly wrap state->locked_group and ->group
These values weren't wrapped before, which caused group_index_is_active
to stop working after a few group switches.

Also, the current group-wrapping function didn't take into consideration
actions such as LockGroup=-1, which need to wrap around, etc.
xkb_layout_index_t is unsigned, but it was used to hold possibly
negative values (e.g. locked_group is 0 and gets a -1 action).

This group wrapping function should now act like the XkbAdjustGroup
function from xserver, and at least ./test/interactive doesn't bring up
any problems with group switching any more.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita 7d1db12dbb state: separate group wrapping/clamping to a function
We'll need this function for wrapping our global effective group as
well.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita ed78fbcb30 state: special case effective group in layout_is_active
Currently, xkb_state_layout_{index,name}_is_active may report multiple
groups as effective, because at looks at base,latched,locked separately.
But there can only be one effective group, which is computed from the
other three. So if XKB_STATE_EFFECTIVE is requested, just compare to the
effective group we have computed.

We also modify mod_{index,name}_is_active similarly, just for symmetry
(there the effective mask is just an OR of the other three so the
current test is correct).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita a8b932a032 symbols: remove useless identical groups optimization
What this code does is, in case someone compile a keymap like -layout
'us,us,us' then only one group would be created. If there is anything
which differentiates between any of the groups (e.g. a variant, another
layout), then this is not done.
This is pretty obscure, only saves a few kbytes in the final keymap, and
if the user asked for it, why not let her?

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita 95b2344849 symbols: avoid reverse iteration in PrepareKeyDef
No need for that.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita c174173209 Don't choke on RMLVO layout string with holes
This old rules parser gives the same kccgst here, so in the interest of
staying compatible we shouldn't fix it there. Similarly we shouldn't
touch ParseIncludeMap, so this is the best place to handle this.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita bbaa11c6e3 Rename map.{c,h} to keymap.{c,h}
Seeing as we don't like "map" anymore.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita 7dca986e3f state, map: check XkbKey != NULL where missing
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita debd62b59b Move xkb_state functions from map.c to state.c
Seems more appropriate.
Only change is to turn some xkb_state_get_map functions to direct
state->keymap.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita d206ecd9e3 Rename private xkb_map_new to xkb_keymap_new
To be consistent with the API rename.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Ran Benita fcd202909b Don't use xkbcommon-compat names in internal code
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24 09:08:53 +10:00
Daniel Stone bf19408078 Promote keymap enumeration API to public
Rename the functions to get keysyms by key/layout/level to fit with the
recent public API renames, and expose them.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-24 09:08:53 +10:00
Daniel Stone 33a66515d6 API change: Rename xkb_map_* and group -> layout
Move xkb_map_* functions to xkb_keymap_*, xkb_key_* functions under
either xkb_keymap or xkb_state, and rename groups to layout in all
user-visible API.

Backwards-compatible hooks are provided, such that old source will
build, but silently mangled to the new names, and old binaries will
also continue to work.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-20 23:30:23 +10:00
Daniel Stone 005dee2bb6 Add _xkbcommon_ prefix to parser and lexer symbols
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-20 23:30:17 +10:00
Daniel Stone 80e156814d Add xkbcommon-compat.h and compat.c
So we can start renaming stuff while retaining backwards source and
binary compatibility.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-20 23:29:45 +10:00
Ran Benita 6b66afc4e7 state: handle ACTION_LOCK_NO_{UN,}LOCK for mods
xkblib spec says:
    XkbSA_LockNoLock    If set, and the action type is XkbSA_LockMods,
                        the server only unlocks the action modifiers.
    XkbSA_LockNoUnlock  If set, and the action is XkbSA_LockMods,
                        the server only locks the action modifiers.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-19 15:56:07 +03:00
Ran Benita 9c2a5c6c61 xkbcomp/keymap: correct ACTION_MODS_LOOKUP_MODS handling
The xkblib spec says:
    If XkbSA_UseModMapMods is not set in the flags field, the mask,
    real_mods, vmods1, and vmods2 fields are used to determine the
    action modifiers. Otherwise they are ignored and the modifiers
    bound to the key (client map->modmap[keycode]) are used instead.

So we should just assign the modmap without considering what's there.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-19 15:23:35 +03:00
Ran Benita 9aee332e9f Fix a couple of mistakes from previous commits
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-18 17:31:55 +03:00
Rob Bradford de4098a024 keysym-utf8: Optimise the keysym to utf8 lookup
This change adds range checks based on the lowest keysym and highest keysym in
the table. This allows a quick check to be applied to identify if the keysym
is inside the table.

To really give value to this optimisation the table is split to have a
separate table for the keypad keysyms.

The test suite passes with this change.

Signed-off-by: Rob Bradford <rob@linux.intel.com>
2012-09-18 09:03:40 +10:00
Ran Benita ac872bdfc2 symbols: fix buffer overflow with illegal explicit group
Trying ''./test/interactive -l us:5' causes us to crash.

The <layout>:<N> syntax says to put this layout at the N'th level.
However the code (inherited from xkbcomp) doesn't check that the group
is valid, and then happily indexes keyi->groups with it, which has a
static size of XKB_NUM_GROUPS (the SetExplicitGroup function assumes the
index is valid). So any value a user might put there > 4 makes nice
things happen.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-17 14:30:16 +03:00
Ran Benita b21107056e Organize src/ and test/ headers
- Add context.h and move context-related functions from xkb-priv.h to
  it.
- Move xkb_context definition back to context.c.
- Add keysym.h and move keysym upper/lower/keypad from xkb-priv.h to it.
- Rename xkb-priv.h to map.h since it only contains keymap-related
  definitions and declarations now.
- Remove unnecessary includes and some and some other small cleanups.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-16 15:20:18 +03:00
Ran Benita e670d084a6 include: improve file-not-found error reporting
Only report it once, and not only for rules.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-16 15:20:18 +03:00
Ran Benita 09a4f2ca89 keycodes: add KeyNameInfo
Instead of keeping the two files and names arrays.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-15 13:45:55 +03:00
Ran Benita b979a5e95e keycodes: rename computedMin/Max to min/max_key_code
min/max_key_code is more descriptive and matches the names of these
field in xkb_keymap.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-15 02:25:47 +03:00
Ran Benita 4b69d6f71d keycodes: ignore explicit minimum/maximum statements
These statements are pretty pointless for us; we don't restrict keycodes
like X does, and if someone writes e.g. maximum = 255 but only has 100
keys, we currently happily alloc all those empty keys. xkbcomp already
handles the case when these statements aren't given, and uses a computed
min/max instead. We should just always use that.
(Of course since keycodes/evdev currently uses almost all of the
keycodes in the range it declares, including 255, this doesn't save any
memory for the common user right now).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-15 02:09:34 +03:00
Ran Benita c53122cb96 symbols: remove useless grow_alloc of keys array
This just does a big, mostly too big, allocation to save about a dozen
malloc calls. Remove it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:53:27 +03:00
Ran Benita 9a27ac7253 state: use filter->priv instead of modifying the action
in xkb_filter_group_set_new.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:09:49 +03:00
Ran Benita 8098daa08f state: move filter initialization to the dispatcher
This removes all of the boilerplate from the *_new functions, and leaves
them just as simple functions which perform the effect of the action on state.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:09:49 +03:00
Ran Benita 2c19c9388b state: call xkb_filter_new from the dispatcher
Pass the new filter as a parameter instead of getting a new one in each
action function, and introducing a failure condition there.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:09:49 +03:00
Ran Benita 04f1b3be07 state: dispatch actions from a table
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:09:49 +03:00
Ran Benita 18a0ead587 Rename ACTION_TYPE_LAST to _ACTION_TYPE_NUM_ENTRIES
It's not really "last" per-se, and we use this other format in some
other enums.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:09:49 +03:00
Ran Benita 16425ffad9 state: don't keep the xkb_state in the filters
Just pass it as a parameter: to make state.c a bit less stateful.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:09:49 +03:00
Ran Benita c2570d51d1 state, map: constify references to xkb_key
Makes it clear that we treat the keys as immutible values in these
files.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:09:49 +03:00
Ran Benita 841f32230a state, map: use keycodes only for the API functions
The policy is now consistent: every API functions which recieves a
keycode should resolve it to an xkb_key first thing, and all the
internal functions use that instead of the keycode.
To facilitate it a bit, we move the KeycodeInRange check to XkbKey
itself, which returns NULL if the keycode is illegal.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:09:49 +03:00
Ran Benita 4d3d2ef004 rules: fix mmap failure handling
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:09:49 +03:00
Ran Benita 96c21e1577 Clean up Init/Clear functions
- The Clear* functions should just free the memory associated with the
  object. If the object is used again, it is Init'd again.
- s/Free/Clear if the actual pointer is not free'd.
- Zeroise object in Init and only initialize non-zero fields.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 21:09:48 +03:00
Ran Benita 7b5a1dd556 symbols: refactor CoypSymbolsDef
To make it easier to follow.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 00:07:55 +03:00
Ran Benita 4c16b39f31 symbols: FindAutomaticType only needs the context
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-14 00:07:55 +03:00
Ran Benita dd6124ca07 symbols: store actions from symbols in the right offset
This regression was introduced in 93ce9c7d4f. 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>
2012-09-13 21:09:48 +03:00
Ran Benita 898d6fd416 symbols: remove CopyKeyInfo
The code is better without it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-13 21:09:48 +03:00
Ran Benita 3abfe83e11 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>
2012-09-13 21:09:46 +03:00
Ran Benita 1d6bffc904 symbols: add CopySymbolsToKeymap
Like in the other sections.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-13 15:57:10 +03:00
Ran Benita 376e45eb6d 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>
2012-09-13 15:57:10 +03:00
Ran Benita 77ab928e92 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>
2012-09-13 15:57:10 +03:00
Ran Benita ce5dbeff60 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>
2012-09-13 15:57:10 +03:00
Ran Benita ca87031861 symbols: make xkb_key::syms a plain array
It's never resized.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-13 15:57:10 +03:00
Ran Benita ee3ade3924 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>
2012-09-13 15:57:10 +03:00
Ran Benita 3cfcbbab38 symbols: consolidate group merging in MergeGroups
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-13 15:57:10 +03:00
Ran Benita db45d664d3 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>
2012-09-13 15:57:10 +03:00
Ran Benita a9fa37396f 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>
2012-09-13 15:57:10 +03:00
Ran Benita 2a5b0c9dc1 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>
2012-09-13 15:57:09 +03:00
Ran Benita 886b0ca502 state: remove unused next field from xkb_filter
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-13 15:57:09 +03:00
Daniel Stone b4b40d73ad 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>
2012-09-12 16:58:54 +01:00
Daniel Stone 14cd8c79cd 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>
2012-09-11 17:00:38 +01:00
Daniel Stone 82de180ede Remove unused ExprResolveKeyName
The only user was removed in 314965b1.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-11 15:09:37 +01:00