platform/upstream/libxkbcommon.git
11 years agokeymap: abstract a bit over the keymap format
Ran Benita [Fri, 1 Mar 2013 19:48:02 +0000 (21:48 +0200)]
keymap: abstract a bit over the keymap format

Make it a bit easier to experiment with other formats.

Add a struct xkb_keymap_format_operations, which currently contains the
keymap compilation and _get_as_string functions. Each format can
implement whatever it wants from these.

The current public entry points become wrappers which do some error
reporting, allocation etc., and calling to the specific format. The
wrappers are all moved to src/keymap.c, so there are no XKB_EXPORT's
under src/xkbcomp/ anymore.

The only format available now is normal text_v1.

This is all not very KISS, and adds some indirection, but it is helpful
and somewhat cleaner.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotext: some style changes
Ran Benita [Fri, 1 Mar 2013 19:31:08 +0000 (21:31 +0200)]
text: some style changes

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotext: clean up and fix the *MaskText functions
Ran Benita [Fri, 1 Mar 2013 16:33:40 +0000 (18:33 +0200)]
text: clean up and fix the *MaskText functions

The snprintf trick that LedStateText and ControlMaskText do cannot work,
because you can't use the buffer as an argument to write to itself!
(posix at least has 'restrict' there). So those two actually never
worked for more than one value (i.e. with a +).

Fix that, and do the same cleanup to ModMaskText. Now we have 3
functions which look exactly the same, oh well.

Also increase the context text buffer size, you never know.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoMore spelling errors
Ran Benita [Fri, 1 Mar 2013 11:51:13 +0000 (13:51 +0200)]
More spelling errors

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest/rmlvo-to-kccgst: free memory before exit
Ran Benita [Thu, 28 Feb 2013 19:06:35 +0000 (21:06 +0200)]
test/rmlvo-to-kccgst: free memory before exit

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoparser: also skip 'section' ELEMENT
Ran Benita [Mon, 25 Feb 2013 15:00:53 +0000 (17:00 +0200)]
parser: also skip 'section' ELEMENT

It's for geometry only.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoast-build: remove malloc_or_die
Ran Benita [Mon, 25 Feb 2013 14:38:56 +0000 (16:38 +0200)]
ast-build: remove malloc_or_die

This should be fixed properly.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: fix spelling in error message
Ran Benita [Mon, 25 Feb 2013 14:08:08 +0000 (16:08 +0200)]
keycodes: fix spelling in error message

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoRemove list.h
Ran Benita [Mon, 25 Feb 2013 10:37:28 +0000 (12:37 +0200)]
Remove list.h

We don't use it anymore and it's easy to add back if needed.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoMakefile.am: don't create INSTALL and ChangeLog
Ran Benita [Mon, 25 Feb 2013 10:27:24 +0000 (12:27 +0200)]
Makefile.am: don't create INSTALL and ChangeLog

It may be xorg standard but it's completely useless and clutter the
directory.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap-dump: move writing 'key {}' in symbols to its own function
Ran Benita [Mon, 25 Feb 2013 10:17:27 +0000 (12:17 +0200)]
keymap-dump: move writing 'key {}' in symbols to its own function

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap-dump: remove some ugly empty lines
Ran Benita [Mon, 25 Feb 2013 10:09:17 +0000 (12:09 +0200)]
keymap-dump: remove some ugly empty lines

xkbcomp prints them too, but that's just annoying. Also xkb_keycodes
doesn't have it already.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap-dump: don't indent after xkb_keymap {
Ran Benita [Mon, 25 Feb 2013 10:03:06 +0000 (12:03 +0200)]
keymap-dump: don't indent after xkb_keymap {

xkbcomp doesn't indent there, so it's easier to diff.
Also saves some horizontal space which is sorely needed when looking at
these files (especially the xkb_symbols).

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap-dump: style cleanups
Ran Benita [Mon, 25 Feb 2013 09:50:26 +0000 (11:50 +0200)]
keymap-dump: style cleanups

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoast: add error handling to XkbFileFromComponents
Ran Benita [Sun, 24 Feb 2013 23:12:38 +0000 (01:12 +0200)]
ast: add error handling to XkbFileFromComponents

And try to not repeat ourselves.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoFix dead assignments
Ran Benita [Sun, 24 Feb 2013 22:19:51 +0000 (00:19 +0200)]
Fix dead assignments

"Value stored to 'stmt' is never read"
"Value stored to 'grp_to_use' is never read"

And change 'grp' to 'group' if we're here.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeysym: print unicode keysyms uppercase and 0-padded
Ran Benita [Tue, 19 Feb 2013 13:57:14 +0000 (15:57 +0200)]
keysym: print unicode keysyms uppercase and 0-padded

Use the same format as XKeysymToString.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoChange some log functions to take ctx instead of keymap
Ran Benita [Thu, 7 Feb 2013 22:07:28 +0000 (00:07 +0200)]
Change some log functions to take ctx instead of keymap

They don't need the keymap, only the context.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: some minor style
Ran Benita [Sat, 9 Feb 2013 19:46:09 +0000 (21:46 +0200)]
keycodes: some minor style

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoaction: s/hndlrType/handler_type
Ran Benita [Fri, 8 Feb 2013 12:03:36 +0000 (14:03 +0200)]
action: s/hndlrType/handler_type

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: make it clear which 'dflt' is meant
Ran Benita [Fri, 8 Feb 2013 14:06:35 +0000 (16:06 +0200)]
compat: make it clear which 'dflt' is meant

Also s/dflt/default.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: make it clear which 'dflt' is meant
Ran Benita [Thu, 7 Feb 2013 21:28:18 +0000 (23:28 +0200)]
symbols: make it clear which 'dflt' is meant

A bit easier at a glance. Also, vowels are cool, so just say 'default'.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoast: constify argument
Ran Benita [Thu, 7 Feb 2013 22:02:49 +0000 (00:02 +0200)]
ast: constify argument

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: fix bad 'merge' assignment
Ran Benita [Tue, 19 Feb 2013 09:10:23 +0000 (11:10 +0200)]
symbols: fix bad 'merge' assignment

Bug introduced in 2a5b0c9dc1ad1488ecc6b139fd70e464eb687da6, was causing
some keys to be merged incorrectly.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoChange 'indicator' to 'led' everywhere possible
Ran Benita [Sun, 17 Feb 2013 20:18:57 +0000 (22:18 +0200)]
Change 'indicator' to 'led' everywhere possible

The code currently uses the two names interchangeably.
Settle on 'led', because it is shorter, more recognizable, and what we
use in our API (though of course the parser still uses 'indicator').

In camel case we make it 'Led'.
We change 'xkb_indicator_map' to just 'xkb_led' and the variables of
this type are 'led'. This mimics 'xkb_key' and 'key'.
IndicatorNameInfo and LEDInfo are changed to 'LedNameInfo' and
'LedInfo', and the variables are 'ledi' (like 'keyi' etc.). This is
instead of 'ii' and 'im'.

This might make a few places a bit confusing, but less than before I
think. It's also shorter.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest/interactive: change variable name for 'xkb' to 'keymap'
Ran Benita [Sun, 17 Feb 2013 20:50:12 +0000 (22:50 +0200)]
test/interactive: change variable name for 'xkb' to 'keymap'

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: fix unbound virtual modifier bug
Ran Benita [Sun, 17 Feb 2013 12:59:50 +0000 (14:59 +0200)]
state: fix unbound virtual modifier bug

Recent xkeyboard-config introduced the following line in symbols/level3:
    vmods = LevelThree,
However, the XKM format which xkbcomp produces for the X server can't
handle explicit virtual modifiers such as this:
https://bugs.freedesktop.org/show_bug.cgi?id=4927

So by doing the following, for example:

setxkbmap -layout de (or another 3-level layouts)
xkbcomp $DISPLAY out.xkb
xkbcomp out.xkb $DISPLAY

The modifier is lost and can't be used for switching to Level3 (see the
included test).

We, however, are affected worse by this bug when we load the out.xkb
keymap. First, the FOUR_LEVEL_ALPHABETIC key type has these entries:
    map[None] = Level1;
    map[Shift] = Level2;
    map[Lock]  = Level2;
    map[LevelThree] = Level3;
    [...]
Now, because the LevelThree virtual modifier is not bound to anything,
the effective mask of the "map[LevelThree]" entry is just 0. So when
the modifier state is empty (initial state), this entry is chosen, and
we get Level3, instead of failing to match any entry and getting the
default Level1.

The difference in behavior from the xserver stems from this commit:
acdad6058d52dc8a3e724dc95448300850d474f2
Which removed the entry->active field. Without bugs, this would be
correct; however, it seems in this case we should just follow the
server's behavior.

The server sets the entry->active field like so in XKBMisc.c:
    /* entry is active if vmods are bound */
    entry->active = (mask != 0);
The xkblib spec explains this field, but does not specify how to
initialize it. This commit does the same as above but more directly.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest/interactive: also print the level
Ran Benita [Sun, 17 Feb 2013 12:32:36 +0000 (14:32 +0200)]
test/interactive: also print the level

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest/keyseq: re-add de(neo) level5 test
Ran Benita [Sun, 17 Feb 2013 11:39:41 +0000 (13:39 +0200)]
test/keyseq: re-add de(neo) level5 test

See:
https://bugs.freedesktop.org/show_bug.cgi?id=50935
This works now after syncing with recent xkeyboard-config.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoSync test data from xkeyboard-config
Ran Benita [Sun, 17 Feb 2013 09:22:41 +0000 (11:22 +0200)]
Sync test data from xkeyboard-config

Sync the files again from xkeyboard-config 2.8, since there have been
some changes we should test against.

Also added a script test/data/sync.sh if we want to do it again in the
future.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoconfigure.ac: add xkbcommon.com url to AC_INIT
Ran Benita [Mon, 10 Dec 2012 20:29:26 +0000 (22:29 +0200)]
configure.ac: add xkbcommon.com url to AC_INIT

Why not.
Also forgot to update the xorg-utils error message when bumping the
requirement.

Signed-off-by: Ran Benita <ran234@gmail.com>
[daniels: Changed to xkbcommon.org.]

11 years agoParser: Initialise geometry elements for VarDecl
Daniel Stone [Thu, 6 Dec 2012 04:04:15 +0000 (15:04 +1100)]
Parser: Initialise geometry elements for VarDecl

We were using uninitialised memory whilst parsing geometry, leaving
random contents as the return for shape/overlay/etc sections.  Somehow
this actually worked everywhere but under Java.

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

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agostate: rename state->cur to state->components
Ran Benita [Sun, 11 Nov 2012 14:14:30 +0000 (16:14 +0200)]
state: rename state->cur to state->components

'cur' doesn't make sense anymore. 'components' is a bit long for this,
but not too bad, and nothing better comes to mind.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: don't keep the previous state components in xkb_state
Ran Benita [Sun, 11 Nov 2012 14:06:54 +0000 (16:06 +0200)]
state: don't keep the previous state components in xkb_state

There is really no need to keep this in the struct, we can just allocate
it on the stack when we need to.
Don't know why I did it this way.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap: wrap the layout parameter if it is out of range for the key
Ran Benita [Sat, 10 Nov 2012 22:22:46 +0000 (00:22 +0200)]
keymap: wrap the layout parameter if it is out of range for the key

The functions num_levels_for_key() and get_syms_by_level() have a
'layout' parameter. Currently it is expected that this value is always
legal for the key, as determined by num_layouts_for_key(). However,
there are legitimate use cases for passing an out-of-range layout there,
most probably passing the effective layout, and expecting to get the
keysyms/levels for just this layout. So we wrap it just as we do in the
xkb_state_* functions.

This is also useful for stuff like this:
http://developer.gnome.org/gdk/stable/gdk-Keyboard-Handling.html#gdk-keymap-lookup-key

If this behavior is not desired, the user has the option to check
against num_layouts_for_key herself.

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

Reported-by: Gatis Paeglis <gatis.paeglis@digia.com>
Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoOnly distribute .tar.xz archives
Daniel Stone [Fri, 9 Nov 2012 03:26:49 +0000 (14:26 +1100)]
Only distribute .tar.xz archives

We definitely don't need .gz anymore, and .bz2 seems on its way out.
Mirror what Wayland does, and move to .xz exclusively.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoDon't use trailing enum comma in public headers
Ran Benita [Tue, 6 Nov 2012 22:41:06 +0000 (00:41 +0200)]
Don't use trailing enum comma in public headers

Pretty annoying, but C89 doesn't support that (officially), and it might
cause warning with -pedantic, etc. (though you need -Wsystem-headers to
see them usually). Removing them is not a big deal.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest/keysym: '\e' is non-standard
Ran Benita [Wed, 7 Nov 2012 16:58:18 +0000 (18:58 +0200)]
test/keysym: '\e' is non-standard

test/keysym.c:139:43: warning: non-ISO-standard escape sequence, '\e'
Didn't warn about it before..

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agodoc: clarify that keysym_to_utf8 returns size including '\0'
Ran Benita [Tue, 6 Nov 2012 21:00:55 +0000 (23:00 +0200)]
doc: clarify that keysym_to_utf8 returns size including '\0'

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeysym-utf: mark keysymtab array as static
Ran Benita [Mon, 5 Nov 2012 19:50:38 +0000 (21:50 +0200)]
keysym-utf: mark keysymtab array as static

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeysym-utf: also translate special keysyms like Tab and Return
Ran Benita [Mon, 5 Nov 2012 19:34:59 +0000 (21:34 +0200)]
keysym-utf: also translate special keysyms like Tab and Return

The keysym2ucs.c file apparently leaves out some keysyms, which libX11
deals with separately (like in _XkbHandleSpecialSym()).
The problematic keysyms are the keypad ones (for which we already added
some support) and keysyms which use 0xff** instead of 0x00** < 0x20.
This code should fix them properly, as much as I could gather from
libX11 and http://www.cl.cam.ac.uk/~mgk25/ucs/keysym2ucs.c and other
sources (which are not aware of locale).

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

Reported-by: Gatis Paeglis <gatis.paeglis@digia.com>
Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoAdd some explanations on consumed modifiers
Ran Benita [Sun, 4 Nov 2012 14:07:30 +0000 (16:07 +0200)]
Add some explanations on consumed modifiers

This should hopefully clarify this somewhat subtle point to the
uninitiated users.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoaction: don't allow private actions with a known type
Ran Benita [Tue, 30 Oct 2012 16:21:56 +0000 (18:21 +0200)]
action: don't allow private actions with a known type

Some obscure bug having to do with Private actions; see the comments.
This was prompted by:
https://bugs.freedesktop.org/show_bug.cgi?id=56491

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agobuild: Require xorg macros 1.16
Damien Lespiau [Thu, 25 Oct 2012 23:51:56 +0000 (00:51 +0100)]
build: Require xorg macros 1.16

For XORG_TESTSET_CFLAG and XORG_MEMORY_CHECK_FLAGS.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Cc: Daniel Stone <daniel@fooishbar.org>
11 years agobuild: Make autoreconf honour ACLOCAL_FLAGS
Damien Lespiau [Thu, 25 Oct 2012 23:51:46 +0000 (00:51 +0100)]
build: Make autoreconf honour ACLOCAL_FLAGS

When running autoreconf, it's possible to give flags to the underlying
aclocal by declaring a ACLOCAL_AMFLAGS variable in the top level
Makefile.am.

Putting ${ACLOCAL_FLAGS} there allows the user to set an environment
variable up before running autogen.sh and pull in the right directories
to look for m4 macros, say an up-to-date version of the xorg-util macros.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Cc: Daniel Stone <daniel@fooishbar.org>
11 years agotest/keyseq: add test for setting depressed group
Ran Benita [Mon, 29 Oct 2012 18:20:51 +0000 (20:20 +0200)]
test/keyseq: add test for setting depressed group

Tests the SetGroup action is working properly.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate, context: allow passing NULL to *_unref()
Ran Benita [Sun, 28 Oct 2012 23:00:27 +0000 (01:00 +0200)]
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>
11 years agostate: don't use xkb_keymap_num_layouts internally
Ran Benita [Fri, 26 Oct 2012 14:24:11 +0000 (16:24 +0200)]
state: don't use xkb_keymap_num_layouts internally

Clearer and more greppable this way.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agodoc: fix wrong comment
Ran Benita [Fri, 26 Oct 2012 14:15:27 +0000 (16:15 +0200)]
doc: fix wrong comment

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: don't use xkb_state_serialize_* internally
Ran Benita [Fri, 26 Oct 2012 14:12:28 +0000 (16:12 +0200)]
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>
11 years agoMakefile.am: move test.h to libtest_la_SOURCES
Ran Benita [Fri, 26 Oct 2012 13:05:04 +0000 (15:05 +0200)]
Makefile.am: move test.h to libtest_la_SOURCES

Rather than EXTRA_DIST, where it doesn't belong.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoMakefile.am: split sed script into multiple lines
Ran Benita [Fri, 26 Oct 2012 13:00:33 +0000 (15:00 +0200)]
Makefile.am: split sed script into multiple lines

To make it visible on one screen.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoconfigure.ac: don't tramp on user's CFLAGS
Ran Benita [Fri, 26 Oct 2012 12:43:15 +0000 (14:43 +0200)]
configure.ac: don't tramp on user's CFLAGS

The configure test shouldn't touch CFLAGS, because they come last on the
command line and allow to users to override settings if needed.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoconfigure.ac: add explicit PKG_PROG_PKG_CONFIG
Ran Benita [Fri, 26 Oct 2012 12:23:07 +0000 (14:23 +0200)]
configure.ac: add explicit PKG_PROG_PKG_CONFIG

We still use pkg-config to get the xkb_base variable from
xkeyboard-config, but we removed all of the other PKG_ macro calls. This
still works now, because XORG_DEFAULT_OPTIONS runs it somehow. But we
shouldn't rely on it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest: add key processing benchmark
Ran Benita [Wed, 24 Oct 2012 21:27:40 +0000 (23:27 +0200)]
test: add key processing benchmark

This runs a bunch of random keys against xkb_state_update_key() and
xkb_state_key_get_one_sym(), in a fairly unintelligent way.

It might be nice to check when modifying this code path, or changing it,
to see things haven't slowed down considerably. However, given the
numbers this benchmark gives, it is pretty clear that we are not going
to be the bottleneck for anything. So this can more-or-less be ignored.

Incidentally, this also turned out to be a poor man's fuzzer, because it
turned up the fix in the previous commit. Maybe we should consider
beefing it up with an actual 'break stuff' intention and running it as
part of 'make check'.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: fix possible index-out-of-bounds in action dispatch table
Ran Benita [Wed, 24 Oct 2012 21:09:26 +0000 (23:09 +0200)]
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>
11 years agoMore README
Daniel Stone [Wed, 24 Oct 2012 06:38:28 +0000 (17:38 +1100)]
More README

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoREADME updates
Daniel Stone [Wed, 24 Oct 2012 06:00:24 +0000 (17:00 +1100)]
README updates

Good thing I didn't check this before I made a release.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoBump to 0.2.0 xkbcommon-0.2.0
Daniel Stone [Tue, 23 Oct 2012 13:34:07 +0000 (00:34 +1100)]
Bump to 0.2.0

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agodoc: various fixes
Ran Benita [Mon, 22 Oct 2012 16:14:39 +0000 (18:14 +0200)]
doc: various fixes

Just moving around / fixing syntax / grammar.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agodoc: move include_path functions to a separate group
Ran Benita [Tue, 23 Oct 2012 08:25:26 +0000 (10:25 +0200)]
doc: move include_path functions to a separate group

These are 'special intrest' function, like the logging functions, so
it's nice to have them in their own logical group.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest/interactive: use num_layouts_for_key()
Ran Benita [Tue, 23 Oct 2012 08:05:16 +0000 (10:05 +0200)]
test/interactive: use num_layouts_for_key()

This is the more appropriate for a specific key (also considering the
num_layouts() is a bit of a made-up value).

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap: use plain array for keymap->group_names
Ran Benita [Tue, 23 Oct 2012 07:58:11 +0000 (09:58 +0200)]
keymap: use plain array for keymap->group_names

Again it is not resized.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: fix typo in state component copying
Ran Benita [Tue, 23 Oct 2012 15:17:18 +0000 (17:17 +0200)]
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>
11 years agoautogen: use --force instead of --symlink
Daniel Stone [Tue, 23 Oct 2012 13:58:51 +0000 (00:58 +1100)]
autogen: use --force instead of --symlink

--force copies and installs all the autotools support files, rather than
making symlinks, which can sometimes break things when upgrading your
system autotools.  This is what xserver does.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoChange update_mask arguments to read 'depressed' instead of 'base'
Ran Benita [Mon, 22 Oct 2012 19:46:43 +0000 (21:46 +0200)]
Change update_mask arguments to read 'depressed' instead of 'base'

Just to be consistent, as we use 'depressed' everywhere else in the API.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotest/interactive: add option to show state changes
Ran Benita [Mon, 22 Oct 2012 19:16:35 +0000 (21:16 +0200)]
test/interactive: add option to show state changes

Pass -c to see.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoReport which components of the state have changed
Ran Benita [Mon, 22 Oct 2012 19:00:57 +0000 (21:00 +0200)]
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>
11 years agostate: add struct state_components
Ran Benita [Mon, 22 Oct 2012 17:19:43 +0000 (19:19 +0200)]
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>
11 years agoSplit the mods, layout, leds parts of xkb_state_components
Ran Benita [Mon, 22 Oct 2012 18:49:44 +0000 (20:49 +0200)]
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>
11 years agodoc: add note about X11 vs. extended keycodes
Ran Benita [Mon, 22 Oct 2012 15:53:44 +0000 (17:53 +0200)]
doc: add note about X11 vs. extended keycodes

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoSilence a couple of warnings
Ran Benita [Sun, 21 Oct 2012 15:13:25 +0000 (17:13 +0200)]
Silence a couple of warnings

These appear to come and go randomly.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoMove _text() functions from keymap-dump to text.c
Ran Benita [Thu, 18 Oct 2012 21:08:10 +0000 (23:08 +0200)]
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>
11 years agoRemove a couple more uses of static char buffers
Ran Benita [Thu, 18 Oct 2012 20:55:17 +0000 (22:55 +0200)]
Remove a couple more uses of static char buffers

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoContextualize GetBuffer()
Ran Benita [Thu, 18 Oct 2012 20:51:10 +0000 (22:51 +0200)]
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>
11 years agoClean up xkb_sym_interpret a bit
Ran Benita [Thu, 18 Oct 2012 19:04:27 +0000 (21:04 +0200)]
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>
11 years agoCommit and distribute ks_tables.h
Ran Benita [Wed, 17 Oct 2012 17:52:47 +0000 (19:52 +0200)]
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>
11 years agoutils: add and use ARRAY_SIZE macro
Ran Benita [Tue, 16 Oct 2012 19:09:33 +0000 (21:09 +0200)]
utils: add and use ARRAY_SIZE macro

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoAdd xkb_keysym_from_name() flags argument for case-insensitive search
David Herrmann [Tue, 16 Oct 2012 14:05:34 +0000 (16:05 +0200)]
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>
11 years agomakekeys: replace helper with python script and binary search
Ran Benita [Tue, 16 Oct 2012 14:05:33 +0000 (16:05 +0200)]
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>
11 years agoFinish first round of API documentation
Ran Benita [Fri, 5 Oct 2012 14:23:03 +0000 (16:23 +0200)]
Finish first round of API documentation

There are a few @todo's, but nothing serious.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: make mod_index_is_consumed() return -1 on invalid input
Ran Benita [Sat, 13 Oct 2012 11:13:55 +0000 (13:13 +0200)]
state: make mod_index_is_consumed() return -1 on invalid input

Like all the other functions.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoChange log env vars to XKB_LOG_LEVEL/VERBOSITY
Ran Benita [Fri, 12 Oct 2012 08:15:43 +0000 (10:15 +0200)]
Change log env vars to XKB_LOG_LEVEL/VERBOSITY

A bit more consistent and descriptive.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agodoc: use JAVADOC_AUTOBRIEF
Ran Benita [Thu, 11 Oct 2012 16:13:56 +0000 (18:13 +0200)]
doc: use JAVADOC_AUTOBRIEF

Don't have to type @brief all the time.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoast: simplify AppendStmt
Ran Benita [Thu, 11 Oct 2012 19:50:21 +0000 (21:50 +0200)]
ast: simplify AppendStmt

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoMake xkb_keymap_num_leds return the index range instead of active count
Ran Benita [Thu, 11 Oct 2012 14:54:17 +0000 (16:54 +0200)]
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>
11 years agokeymap: rename keymap->sym_interpret -> sym_interprets
Ran Benita [Thu, 11 Oct 2012 12:05:49 +0000 (14:05 +0200)]
keymap: rename keymap->sym_interpret -> sym_interprets

This can be a bit confusing.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: add documentation for interpret's
Ran Benita [Thu, 11 Oct 2012 12:03:03 +0000 (14:03 +0200)]
compat: add documentation for interpret's

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: don't forget to copy XKB_MATCH_NONE interpret's
Ran Benita [Thu, 11 Oct 2012 10:07:43 +0000 (12:07 +0200)]
compat: don't forget to copy XKB_MATCH_NONE interpret's

Commit a8d462e3669b1790dfad75836d5ec59e390392ef accidentally removed the
OR with XKB_MATCH_NONE. It is in fact unused though.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agobuild: change to AM_MAINTAINER_MODE([enable])
Ran Benita [Wed, 10 Oct 2012 19:01:15 +0000 (21:01 +0200)]
build: change to AM_MAINTAINER_MODE([enable])

Disabled maintainer mode is annoying, we have no reason to do it. The
old behavior can still be had with --disable-maintainer-mode.
See:
http://lists.x.org/archives/xorg-devel/2012-September/033757.html
http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/maintainer_002dmode.html

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agobuild: honor $NOCONFIGURE in autogen.sh
Ran Benita [Wed, 10 Oct 2012 18:53:26 +0000 (20:53 +0200)]
build: honor $NOCONFIGURE in autogen.sh

Using NOCONFIGURE=1 ./autogen.sh can prevent it from running ./configure
on its own, which is sometimes useful.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostringcomp: test compilation of a dump of a keymap created from rules
Ran Benita [Wed, 10 Oct 2012 17:14:35 +0000 (19:14 +0200)]
stringcomp: test compilation of a dump of a keymap created from rules

This would have caught the regression fixed in 2ac319c.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoRemove the XKB_NUM_INDICATORS limit
Ran Benita [Wed, 10 Oct 2012 17:08:01 +0000 (19:08 +0200)]
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>
11 years agokeymap: don't use darray for keymap->keys
Ran Benita [Wed, 10 Oct 2012 15:51:06 +0000 (17:51 +0200)]
keymap: don't use darray for keymap->keys

It's never resized.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoRename XKB_NUM_GROUPS to XKB_MAX_GROUPS
Ran Benita [Wed, 10 Oct 2012 15:30:15 +0000 (17:30 +0200)]
Rename XKB_NUM_GROUPS to XKB_MAX_GROUPS

This is a more appropriate name now.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: refactor AddIndicatorName
Ran Benita [Wed, 10 Oct 2012 10:11:43 +0000 (12:11 +0200)]
keycodes: refactor AddIndicatorName

Make it shorter and fix the XXX.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap, state: don't assume led index < xkb_keymap_num_leds
Ran Benita [Wed, 10 Oct 2012 07:47:31 +0000 (09:47 +0200)]
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>
11 years agokeysym: fix xkb_keysym_is_upper/lower() to work properly
Ran Benita [Tue, 9 Oct 2012 18:48:35 +0000 (20:48 +0200)]
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>
11 years agocompat: fix bad interpret predicate mods "all" calculation
Ran Benita [Mon, 8 Oct 2012 20:11:18 +0000 (22:11 +0200)]
compat: fix bad interpret predicate mods "all" calculation

Commit 9984d1d03cd78eb636c75cc2bbd2d240dc1dd72f 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>
11 years agokeymap: use xkb_mod_mask_t for interpret->mods and modmap
Ran Benita [Sat, 6 Oct 2012 19:37:43 +0000 (21:37 +0200)]
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>