platform/upstream/libxkbcommon.git
12 years agoDon't use %z printf format
Ran Benita [Sun, 30 Sep 2012 12:17:08 +0000 (14:17 +0200)]
Don't use %z printf format

Some libc's don't support it.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agorules: always initialize idx variable
Ran Benita [Sun, 30 Sep 2012 10:42:44 +0000 (12:42 +0200)]
rules: always initialize idx variable

gcc didn't catch this one.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agotest: add keycodes files which map directly to evdev codes
Ran Benita [Thu, 27 Sep 2012 18:16:12 +0000 (20:16 +0200)]
test: add keycodes files which map directly to evdev codes

This is a proof-of-concept for the long key names. The keycodes in the
file evdev-xkbcommon are autogenerated from linux/input.h, and uses the
names given there; all of the previous names are aliased to the new
names, so they continue to work with the symbols files, etc.

You can try it with 'sudo ./test/interactive -r evdev-xkbcommon -n 0'
The -n 0 means that we don't offset the evdev scan codes - just feed
them directly. The -r evdev-xkbcommon just means to use a new rules file
which makes us use the new keycodes file. (The only problem I can see is
with the MENU and LSGT names which has some conflicts).

Maybe some day xkeyboard-config could ship something similar, so that
the 8 offset is unneeded.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agokeymap-dump: make it look better with long key names
Ran Benita [Thu, 27 Sep 2012 19:30:29 +0000 (21:30 +0200)]
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>
12 years agotest/interactive: allow to set evdev offset
Ran Benita [Thu, 27 Sep 2012 18:44:16 +0000 (20:44 +0200)]
test/interactive: allow to set evdev offset

If we want to test a keymap without the usual 8 offset.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoFix type of keycode in parser and ast
Ran Benita [Thu, 27 Sep 2012 17:21:26 +0000 (19:21 +0200)]
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>
12 years agoDon't limit key names to 4 characters
Ran Benita [Thu, 27 Sep 2012 16:49:13 +0000 (18:49 +0200)]
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>
12 years agoxkbcomp/keymap: use default interpret in ApplyInterpsToKey
Ran Benita [Thu, 27 Sep 2012 07:19:12 +0000 (09:19 +0200)]
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>
12 years agostate: add missing const in get_one_sym
Ran Benita [Thu, 27 Sep 2012 19:11:11 +0000 (21:11 +0200)]
state: add missing const in get_one_sym

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoAdd xkb_state_key_get_one_sym
Daniel Stone [Thu, 27 Sep 2012 13:27:49 +0000 (23:27 +1000)]
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>
12 years agoFix size_t vs. %d warning
Daniel Stone [Wed, 26 Sep 2012 00:28:52 +0000 (10:28 +1000)]
Fix size_t vs. %d warning

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
12 years agosymbols: get rid of autoType
Ran Benita [Tue, 25 Sep 2012 09:49:23 +0000 (11:49 +0200)]
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>
12 years agosymbols: separate type-finding logic from CopySymbolsDef
Ran Benita [Tue, 25 Sep 2012 09:35:59 +0000 (11:35 +0200)]
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>
12 years agokeymap: remove some more unneeded macros
Ran Benita [Mon, 24 Sep 2012 12:57:30 +0000 (14:57 +0200)]
keymap: remove some more unneeded macros

It clearer to just access the needed data directly.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agokeymap: store a pointer to the type in xkb_group instead of index
Ran Benita [Mon, 24 Sep 2012 12:41:09 +0000 (14:41 +0200)]
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>
12 years agokeymap, symbols: improve xkb_key memory layout
Ran Benita [Mon, 24 Sep 2012 10:11:31 +0000 (12:11 +0200)]
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>
12 years agosymbols: move keysyms into LevelInfo
Ran Benita [Mon, 24 Sep 2012 08:55:20 +0000 (10:55 +0200)]
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>
12 years agosymbols: fix index-out-of-bounds in FindAutomaticType
Ran Benita [Mon, 24 Sep 2012 08:16:09 +0000 (10:16 +0200)]
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>
12 years agosymbols: remove unneeded optimization
Ran Benita [Mon, 24 Sep 2012 07:14:35 +0000 (09:14 +0200)]
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>
12 years agokeymap: use our type for keymap->enabled_ctrls
Ran Benita [Sun, 23 Sep 2012 22:50:19 +0000 (00:50 +0200)]
keymap: use our type for keymap->enabled_ctrls

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoAdd missing declaration for _xkbcommon_parse (aka yyparse)
Daniel Stone [Mon, 24 Sep 2012 04:36:46 +0000 (14:36 +1000)]
Add missing declaration for _xkbcommon_parse (aka yyparse)

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
12 years agokeymap.h: add note on why XKB_NUM_GROUPS is still there
Ran Benita [Sun, 23 Sep 2012 20:32:53 +0000 (22:32 +0200)]
keymap.h: add note on why XKB_NUM_GROUPS is still there

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agokeymap, symbols: use darray for num_groups
Ran Benita [Sun, 23 Sep 2012 20:12:43 +0000 (22:12 +0200)]
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>
12 years agosymbols: avoid possible access-out-of-bound due to explicit_group
Ran Benita [Sun, 23 Sep 2012 19:15:34 +0000 (21:15 +0200)]
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>
12 years agosymbols: rename SymbolsInfo groupNames to group_names
Ran Benita [Sun, 23 Sep 2012 18:38:25 +0000 (20:38 +0200)]
symbols: rename SymbolsInfo groupNames to group_names

Just to match the matching field in the keymap.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agokeymap: don't use XKB_NUM_GROUPS for key->kt_index
Ran Benita [Sun, 23 Sep 2012 18:36:01 +0000 (20:36 +0200)]
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>
12 years agoAdd format argument to xkb_keymap_get_as_string
Ran Benita [Sun, 23 Sep 2012 15:52:51 +0000 (17:52 +0200)]
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>
12 years agoAdd return value the xkb_keysym_get_name
Ran Benita [Sun, 23 Sep 2012 14:57:16 +0000 (16:57 +0200)]
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>
12 years agoImprove API doxygen documentation
Ran Benita [Sun, 23 Sep 2012 14:56:48 +0000 (16:56 +0200)]
Improve API doxygen documentation

To make it look better and a bit more structured and informative.
Not all of the functions are converted to doxygen format, so this is not
finished.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoAdd support for building doxygen API documentation
Ran Benita [Sat, 22 Sep 2012 12:02:54 +0000 (15:02 +0300)]
Add support for building doxygen API documentation

Simple HTML docs generated from the doxygen comments.
After running 'make' or 'make doc', try firefox doc/html/index.html to
see it (if you have doxygen). It's also installed with 'make install'.
You can use --enable-docs or --disable-docs, or specifically
--with-doxygen or --without-doxygen (autodetected, default yes).

The docs are currently not distributed in the tarball, because I
couldn't make it work properly in all cases :/

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoAPI: add _context prefix to log-related functions
Ran Benita [Sat, 22 Sep 2012 07:58:00 +0000 (10:58 +0300)]
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>
12 years agokeymap: remove XkbKeyGetKeycode
Ran Benita [Sat, 22 Sep 2012 07:21:22 +0000 (10:21 +0300)]
keymap: remove XkbKeyGetKeycode

Because we keep the keycode inside the xkb_key now.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: convert KeyInfo->groups to darray
Ran Benita [Fri, 21 Sep 2012 23:05:48 +0000 (02:05 +0300)]
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>
12 years agosymbols: fix memleak from default KeyInfo
Ran Benita [Fri, 21 Sep 2012 23:36:05 +0000 (02:36 +0300)]
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>
12 years agosymbols: disallow changing global defaults from within a key statement
Ran Benita [Fri, 21 Sep 2012 22:30:01 +0000 (01:30 +0300)]
symbols: disallow changing global defaults from within a key statement

Pretty much like e5fdbcbb9943e9fe, again it isn't used.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: fold PrepareKeyDef into CopySymbolsDef
Ran Benita [Fri, 21 Sep 2012 18:39:15 +0000 (21:39 +0300)]
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>
12 years agostate: missing XKB_EXPORT on xkb_state_key_get_level
Ran Benita [Fri, 21 Sep 2012 18:16:20 +0000 (21:16 +0300)]
state: missing XKB_EXPORT on xkb_state_key_get_level

And some error handling.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoconfigure.ac: use XORG_TESTSET_CFLAG for -fvisibility=hidden
Ran Benita [Fri, 21 Sep 2012 17:09:17 +0000 (20:09 +0300)]
configure.ac: use XORG_TESTSET_CFLAG for -fvisibility=hidden

Probably shouldn't use CFLAGS for that but o well.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoconfigure.ac: add XORG_MEMORY_CHECK_FLAGS
Ran Benita [Fri, 21 Sep 2012 16:57:37 +0000 (19:57 +0300)]
configure.ac: add XORG_MEMORY_CHECK_FLAGS

Adds some memory checking (e.g. MALLOC_PERTURB_) to tests.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoconfigure.ac: remove XORG_CHECK_MALLOC_ZERO
Ran Benita [Fri, 21 Sep 2012 16:48:33 +0000 (19:48 +0300)]
configure.ac: remove XORG_CHECK_MALLOC_ZERO

We don't use its result.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoconfigure.ac: fix bug report url
Ran Benita [Fri, 21 Sep 2012 15:39:01 +0000 (18:39 +0300)]
configure.ac: fix bug report url

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agostate: correctly wrap state->locked_group and ->group
Ran Benita [Fri, 21 Sep 2012 13:30:01 +0000 (16:30 +0300)]
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>
12 years agostate: separate group wrapping/clamping to a function
Ran Benita [Fri, 21 Sep 2012 12:39:32 +0000 (15:39 +0300)]
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>
12 years agostate: special case effective group in layout_is_active
Ran Benita [Fri, 21 Sep 2012 09:45:58 +0000 (12:45 +0300)]
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>
12 years agosymbols: remove useless identical groups optimization
Ran Benita [Fri, 21 Sep 2012 09:23:56 +0000 (12:23 +0300)]
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>
12 years agosymbols: avoid reverse iteration in PrepareKeyDef
Ran Benita [Fri, 21 Sep 2012 08:54:35 +0000 (11:54 +0300)]
symbols: avoid reverse iteration in PrepareKeyDef

No need for that.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoDon't choke on RMLVO layout string with holes
Ran Benita [Fri, 21 Sep 2012 08:14:39 +0000 (11:14 +0300)]
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>
12 years agoRename map.{c,h} to keymap.{c,h}
Ran Benita [Fri, 21 Sep 2012 11:58:31 +0000 (14:58 +0300)]
Rename map.{c,h} to keymap.{c,h}

Seeing as we don't like "map" anymore.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agostate, map: check XkbKey != NULL where missing
Ran Benita [Fri, 21 Sep 2012 11:55:46 +0000 (14:55 +0300)]
state, map: check XkbKey != NULL where missing

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoMove xkb_state functions from map.c to state.c
Ran Benita [Fri, 21 Sep 2012 10:30:42 +0000 (13:30 +0300)]
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>
12 years agoRename private xkb_map_new to xkb_keymap_new
Ran Benita [Fri, 21 Sep 2012 11:00:00 +0000 (14:00 +0300)]
Rename private xkb_map_new to xkb_keymap_new

To be consistent with the API rename.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoDon't use xkbcommon-compat names in internal code
Ran Benita [Fri, 21 Sep 2012 11:44:17 +0000 (14:44 +0300)]
Don't use xkbcommon-compat names in internal code

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoPromote keymap enumeration API to public
Daniel Stone [Wed, 19 Sep 2012 06:19:57 +0000 (16:19 +1000)]
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>
12 years agoAPI change: Rename xkb_map_* and group -> layout
Daniel Stone [Wed, 12 Sep 2012 18:55:06 +0000 (19:55 +0100)]
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>
12 years agoAdd _xkbcommon_ prefix to parser and lexer symbols
Daniel Stone [Thu, 20 Sep 2012 13:28:27 +0000 (23:28 +1000)]
Add _xkbcommon_ prefix to parser and lexer symbols

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
12 years agoAdd xkbcommon-compat.h and compat.c
Daniel Stone [Wed, 12 Sep 2012 18:52:30 +0000 (19:52 +0100)]
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>
12 years agotest: add print-compiled-keymap tool
Ran Benita [Wed, 19 Sep 2012 13:44:15 +0000 (16:44 +0300)]
test: add print-compiled-keymap tool

This just prints the compiled keymap string for to the given command
line arguments. This often useful when developing.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agostate: handle ACTION_LOCK_NO_{UN,}LOCK for mods
Ran Benita [Wed, 19 Sep 2012 12:56:07 +0000 (15:56 +0300)]
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>
12 years agoxkbcomp/keymap: correct ACTION_MODS_LOOKUP_MODS handling
Ran Benita [Wed, 19 Sep 2012 12:23:35 +0000 (15:23 +0300)]
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>
12 years agoFix a couple of mistakes from previous commits
Ran Benita [Tue, 18 Sep 2012 14:31:55 +0000 (17:31 +0300)]
Fix a couple of mistakes from previous commits

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agokeysym-utf8: Optimise the keysym to utf8 lookup
Rob Bradford [Fri, 14 Sep 2012 16:50:31 +0000 (17:50 +0100)]
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>
12 years agosymbols: fix buffer overflow with illegal explicit group
Ran Benita [Mon, 17 Sep 2012 11:24:38 +0000 (14:24 +0300)]
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>
12 years agokeyseq: add test for repeat-shift-repeat-unshift-repeat
Ran Benita [Sun, 16 Sep 2012 12:57:36 +0000 (15:57 +0300)]
keyseq: add test for repeat-shift-repeat-unshift-repeat

e.g. hhhhhHHHHHHHhhhhhh with shift down and up in the middle.
Unfortunately trying a quick test with test/interactive is not possible
because the evdev soft-repeat stops the repeat when another key is
pressed. So you need real soft-repeat for that.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoOrganize src/ and test/ headers
Ran Benita [Sun, 16 Sep 2012 11:45:32 +0000 (14:45 +0300)]
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>
12 years agoinclude: improve file-not-found error reporting
Ran Benita [Sun, 16 Sep 2012 10:33:09 +0000 (13:33 +0300)]
include: improve file-not-found error reporting

Only report it once, and not only for rules.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agokeycodes: add KeyNameInfo
Ran Benita [Sat, 15 Sep 2012 10:39:14 +0000 (13:39 +0300)]
keycodes: add KeyNameInfo

Instead of keeping the two files and names arrays.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agokeycodes: rename computedMin/Max to min/max_key_code
Ran Benita [Fri, 14 Sep 2012 23:24:17 +0000 (02:24 +0300)]
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>
12 years agokeycodes: ignore explicit minimum/maximum statements
Ran Benita [Fri, 14 Sep 2012 23:09:34 +0000 (02:09 +0300)]
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>
12 years agosymbols: remove useless grow_alloc of keys array
Ran Benita [Fri, 14 Sep 2012 18:53:27 +0000 (21:53 +0300)]
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>
12 years agostate: use filter->priv instead of modifying the action
Ran Benita [Fri, 14 Sep 2012 13:10:47 +0000 (16:10 +0300)]
state: use filter->priv instead of modifying the action

in xkb_filter_group_set_new.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agostate: move filter initialization to the dispatcher
Ran Benita [Fri, 14 Sep 2012 13:01:11 +0000 (16:01 +0300)]
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>
12 years agostate: call xkb_filter_new from the dispatcher
Ran Benita [Fri, 14 Sep 2012 12:33:54 +0000 (15:33 +0300)]
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>
12 years agostate: dispatch actions from a table
Ran Benita [Fri, 14 Sep 2012 12:29:12 +0000 (15:29 +0300)]
state: dispatch actions from a table

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRename ACTION_TYPE_LAST to _ACTION_TYPE_NUM_ENTRIES
Ran Benita [Fri, 14 Sep 2012 12:17:20 +0000 (15:17 +0300)]
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>
12 years agostate: don't keep the xkb_state in the filters
Ran Benita [Fri, 14 Sep 2012 08:26:36 +0000 (11:26 +0300)]
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>
12 years agostate, map: constify references to xkb_key
Ran Benita [Fri, 14 Sep 2012 08:17:30 +0000 (11:17 +0300)]
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>
12 years agostate, map: use keycodes only for the API functions
Ran Benita [Fri, 14 Sep 2012 08:02:12 +0000 (11:02 +0300)]
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>
12 years agorules: fix mmap failure handling
Ran Benita [Thu, 13 Sep 2012 22:09:37 +0000 (01:09 +0300)]
rules: fix mmap failure handling

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoClean up Init/Clear functions
Ran Benita [Thu, 13 Sep 2012 21:21:54 +0000 (00:21 +0300)]
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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>
12 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>