platform/upstream/libxkbcommon.git
11 years agoexpr: move op_type/value_type_to_string functions to ast
Ran Benita [Wed, 15 Aug 2012 18:45:02 +0000 (21:45 +0300)]
expr: move op_type/value_type_to_string functions to ast

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

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

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

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

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

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

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

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

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

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

No need for a list here.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: remove "flags" field from xkb_indicator_map
Ran Benita [Sun, 2 Sep 2012 15:51:26 +0000 (18:51 +0300)]
compat: remove "flags" field from xkb_indicator_map

We don't set this field any more.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: ignore "allowExplicit" in indicator statements
Ran Benita [Thu, 30 Aug 2012 15:56:24 +0000 (18:56 +0300)]
compat: ignore "allowExplicit" in indicator statements

Using !allowExplicit sets the XkbIM_NoExplicit flag of the indicator,
which means that an XKB client cannot change the state of the indicator
using e.g. XkbSetNamedIndicator().
We do not support changing the state of an indicator; furthermore doing
it is probably only useful in conjunction with led-drives-keyboard
behavior, which we also do not support. This is because setting an
indicator without led-drives-keyboard would make the indicator and the
modifier/group it's bound to to get out of sync.

We can re-add this if we need this info.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: ignore "ledDrivesKbd" in indicator statements
Ran Benita [Thu, 30 Aug 2012 13:39:33 +0000 (16:39 +0300)]
compat: ignore "ledDrivesKbd" in indicator statements

We don't support it, as mentioned in the README, so we should stop
processing it and print a message about it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: ignore "group" (compatibility) statements
Ran Benita [Mon, 27 Aug 2012 18:31:18 +0000 (21:31 +0300)]
compat: ignore "group" (compatibility) statements

Group compatibility statements are like the following:
    group 3 = AltGr;
This currently results in:
    keymap->groups[2].mask = <real mod mapped from AltGr vmod>
And we don't do any thing with this value later. The reason it exists in
XKB is to support non-XKB clients (i.e. XKB support disabled entirely in
the server), which do not know the concept of "group", and use some
modifier to distinguish between the first and second keyboard layouts
(usually with the AltGr key). We don't care about all of that, so we can
forget about it.

One artifact of this removal is that xkb_map_num_groups no longer
works, because it counted through keymap->groups (this wasn't entirely
correct BTW). Instead we add a new num_groups member to the keymap,
which just hold the maximum among the xkb_key's num_groups. This also
means we don't have to compute anything just to get the number of
groups.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: get rid of BindIndicators
Ran Benita [Mon, 27 Aug 2012 10:21:03 +0000 (13:21 +0300)]
compat: get rid of BindIndicators

Now that 1fba6189e67 removed support for binding indicator maps by index
instead of name, we can remove some more magic which happens now: if an
indicator map specifies an indicator name which was not previously
declared in a 'indicator 5 = "Caps Lock"'-like statement in
xkb_keycodes, we can just look at the next free index and assign it.

This also allows us to use a darray for the LEDInfo's instead of a list.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: ignore "index" field in indicator statements
Ran Benita [Mon, 27 Aug 2012 09:29:57 +0000 (12:29 +0300)]
compat: ignore "index" field in indicator statements

The current code allows to set the "index" field in an indicator
statment's body. This would bind the indicator to the specified index,
instead of by name (which was declared previously in xkb_keycodes).
Doing this is a bad idea, for the same reasons as in 3cd9704, and is
also happily not used anywhere.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: remove dead NoAutomatic code
Ran Benita [Mon, 27 Aug 2012 08:38:44 +0000 (11:38 +0300)]
compat: remove dead NoAutomatic code

The xkblib spec, table 7.1 (indicators), says:
XkbIM_NoAutomatic: Xkb does not automatically change the value of the
                   indicator based upon a change in the keyboard state,
                   regardless of the values for the other fields of the
                   indicator map.

xkbcomp (the real one) never actually implemented a way for an indicator
statement to set this flag, so it's just dead unused code. We definitely
don't want to implement it ourselves, so remove any mention of it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: ignore "locking" field in sym interprets
Ran Benita [Tue, 14 Aug 2012 13:26:30 +0000 (16:26 +0300)]
compat: ignore "locking" field in sym interprets

This field is used in conjunction with key behaviors, which we don't
support since c1ea23da5. This is also unused in xkeyboard-config.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: small changes
Ran Benita [Tue, 14 Aug 2012 12:06:11 +0000 (15:06 +0300)]
compat: small changes

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agocompat: add general overview
Ran Benita [Tue, 14 Aug 2012 12:05:56 +0000 (15:05 +0300)]
compat: add general overview

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoaction: convert action field type to enum
Ran Benita [Sat, 11 Aug 2012 08:54:05 +0000 (11:54 +0300)]
action: convert action field type to enum

We can also hide the ActionInfo definition inside action.c.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: add "Effects on keymap" to overview
Ran Benita [Tue, 14 Aug 2012 11:42:57 +0000 (14:42 +0300)]
types: add "Effects on keymap" to overview

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agorulescomp: remove bad failtests
Ran Benita [Sun, 12 Aug 2012 15:16:52 +0000 (18:16 +0300)]
rulescomp: remove bad failtests

Since we now handle empty model/layout, the last couple of tests should
not fail. The reason they do is bacause they try to use a non-existent
"base" rules file. When the file is brought in these tests do not fail.
Since we already test for non-existent rules file, we can remove them,
and refine the other tests a bit.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoOrganize xkbcomp/ header files
Ran Benita [Mon, 13 Aug 2012 08:00:43 +0000 (11:00 +0300)]
Organize xkbcomp/ header files

Various non-functional changes:
- Re-add keycodes.h and move some stuff there.
- Add parser-priv.h for internal bison/flex stuff.
- Don't include headers from other headers, such that file dependencies
  are immediate in each file.
- Rename xkbcomp.h -> ast.h, parseutils.{c,h} -> ast-build.{c,h}
- Rename path.{c,h} -> include.{c,h}
- Rename keytypes.c -> types.c
- Make the naming of XkbFile-related functions more consistent.
- Move xkb_map_{new,ref,unref} to map.c.
- Remove most extern keyword from function declarations, it's just
  noise (XKB_EXPORT is what's important here).
- Append XKBCOMP_ to include guards.
- Shuffle some code around to make all of this work.

Splitting this would be a headache..

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoAllocate xkb_component_names on stack
Ran Benita [Tue, 14 Aug 2012 08:49:19 +0000 (11:49 +0300)]
Allocate xkb_component_names on stack

Instead of malloc'ing it as well. Also improve the error handling.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoMove ISEMPTY to utils.h
Ran Benita [Mon, 13 Aug 2012 10:49:17 +0000 (13:49 +0300)]
Move ISEMPTY to utils.h

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoMove 'no symbols defined for ...' message to a warning
Daniel Stone [Thu, 9 Aug 2012 14:47:53 +0000 (16:47 +0200)]
Move 'no symbols defined for ...' message to a warning

Shut up shut up shut up shut up shut up shut up.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoCombine a couple of macros
Ran Benita [Fri, 10 Aug 2012 19:48:18 +0000 (22:48 +0300)]
Combine a couple of macros

Easier to see what it does without the trivial macros.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoaction: get rid of xkb_any_action
Ran Benita [Fri, 10 Aug 2012 19:38:07 +0000 (22:38 +0300)]
action: get rid of xkb_any_action

And use union xkb_action instead. We add xkb_private_action, which is
the same as xkb_any_action, but only used where the intention is clear.
This should take care of whatever sizing changes the action struct might
have.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoRemove XkbKeyTypeIndex and widen index type
Ran Benita [Fri, 10 Aug 2012 19:06:12 +0000 (22:06 +0300)]
Remove XkbKeyTypeIndex and widen index type

We don't need the macro, and using char for the kt_index is imaginably
too small.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoStore actions inside struct xkb_key
Ran Benita [Fri, 10 Aug 2012 15:14:35 +0000 (18:14 +0300)]
Store actions inside struct xkb_key

Cuts out a lot of useless redirection and space.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: save context in Info, not keymap
Ran Benita [Fri, 10 Aug 2012 10:32:58 +0000 (13:32 +0300)]
keycodes: save context in Info, not keymap

We don't need the keymap in this case, just makes things more verbose.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoRemove xkbcomp/misc.c
Ran Benita [Fri, 10 Aug 2012 10:30:44 +0000 (13:30 +0300)]
Remove xkbcomp/misc.c

The KeyName functions are more appropriate in keycodes.c.
The ProcessIncludeFile can go to path.c along with the other functions
dealing with includes.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoRemove left over keycodes.h
Ran Benita [Fri, 10 Aug 2012 10:26:36 +0000 (13:26 +0300)]
Remove left over keycodes.h

For some reason we still track this file in git even though we don't use
it any more.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoRemove AutoKeyNames feature
Ran Benita [Fri, 10 Aug 2012 10:08:03 +0000 (13:08 +0300)]
Remove AutoKeyNames feature

If this keymap flag is set, whenever a key name appears in one of the
sections which does not exist (i.e. has not been declared in keycodes),
it finds the first unused keycode and attaches it that name.

This might have been useful when you could compile the symbols section
or geometry section without a keycodes section, but we don't support
this anymore. It's also pretty useless for any real work, because the
user has no way of knowing the keycode and so it will never be used.
Finally the only obscure way left to set this flag is by including a
keycodes file called "computed".

Just remove it.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agomap: share some code
Ran Benita [Fri, 10 Aug 2012 07:17:32 +0000 (10:17 +0300)]
map: share some code

Make more extensive use of get_entry_for_key_state, and add
key_get_consumed to use in the other consume functions.

There's also a slight change in the consumed mods calculations, where
we use entry->mods.mask instead of type->mods.mask. The original was
copied from what libX11 does but what we do now is more logically
correct. The result is exactly the same though because:
type->mods.mask ⊇ entry->mods.mask ⊇ entry->preserve.mask

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoUse XKB_{GROUP,LEVEL}_INVALID instead of -1 for errors
Ran Benita [Fri, 10 Aug 2012 07:11:49 +0000 (10:11 +0300)]
Use XKB_{GROUP,LEVEL}_INVALID instead of -1 for errors

The group/level types are unsigned, so it's odd to return -1 for them.
Instead use their invalid values (which happen to be == -1).

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agostate: use global static const for fake action
Ran Benita [Fri, 10 Aug 2012 07:08:20 +0000 (10:08 +0300)]
state: use global static const for fake action

Requires constifying some arguments.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoModernize struct xkb_mods
Ran Benita [Wed, 8 Aug 2012 23:33:51 +0000 (02:33 +0300)]
Modernize struct xkb_mods

Currently xkb_mods has the following members:
- uint8_t real_mods - 8 X11 core mods
- xkb_mod_mask_t vmods - 16 virtual mods, zero-based index
- xkb_mod_mask_t mask - the computed effective *real* modifier mask,
  basically a cache for the first two which is:
  real_mods | real mods computed from vmods

Our API acts on masks which combine the real_mods and vmods into a
single value, which is:
8 first bits real mods | 16 next bits virtual mods
(XkbNumModifiers = 8, XkbNumVirtualMods = 16). This is also the format
which ResolveVModMask uses (which is where all the modifier masks really
"come from", e.g. "Shift+Lock+Level5" -> xkb_mod_mask_t).

What the code does now after getting the mask from ResolveVModMask, is
to break it into real part and virtual part and store them seperately,
and then join them back together when the effective mask is calculated.

This is all pretty useless work. We change xkb_mods to the following:
- xkb_mod_mask_t mods - usually what ResolveVModMask returns
- xkb_mod_mask_t mask - the computed mask cache
And try to consistently use the word "mods" for the original,
non-effective mods and mask for the effective mods (which can only
contain real mods for now, because things break otherwise).

The separation is also made clearer. The effective masks are computed by
UpdateModifiersFromCompat after all the sections have been compiled;
before this the mask field is never touched; after this (i.e. map.c and
state.c) the original mods field is never touched. This single execption
to this rule is keymap-dump.c: it needs to print out only the original
modifiers, not computed ones. This is also the reason why we actually
keep two fields instead keeping one and modifying it in place.

The next logical step is probably to turn the real mods into vmods
themselves, and get rid of the distinction entirely (in a compatible
way).

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoFix xkb_keymap::vmods type
Ran Benita [Wed, 8 Aug 2012 23:33:51 +0000 (02:33 +0300)]
Fix xkb_keymap::vmods type

It maps a vmod to a mask, of course.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: don't compute effective masks here as well
Ran Benita [Wed, 8 Aug 2012 22:30:22 +0000 (01:30 +0300)]
types: don't compute effective masks here as well

After compiling all of the sections, UpdateModifiersFromCompat does all
of the vmod -> real mods translations, including types/kt_entries.

keytypes.c also has code that does that, but it's unneeded:
- Later sections don't look at their effective masks, so doing it later
  is fine.
- When this code is executed, the vmods -> real mods mapping is empty
  (that is set up later), so VModsToReal has no effect here.
So we can just remove it.

However UpdateModifiersFromCompat didn't update the preserve mask, so do
that.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: get rid of PreserveInfo
Ran Benita [Wed, 8 Aug 2012 16:53:55 +0000 (19:53 +0300)]
types: get rid of PreserveInfo

We don't need the indirection. We store the preserve mask directly in
the entry, and create a new one if it doesn't exists (which is exactly
what the current code does in a roundabout way).

Incidentally this fixes a bug where the effective modifier mask of the
entries' preserve[] wasn't calculated, so the virtual modifiers had no
effect there.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap-dump: use VModMaskText
Ran Benita [Wed, 8 Aug 2012 17:47:51 +0000 (20:47 +0300)]
keymap-dump: use VModMaskText

The difference between the two are irrelevant here.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoFix warning
Ran Benita [Wed, 8 Aug 2012 22:55:30 +0000 (01:55 +0300)]
Fix warning

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoAdd xkb_map_mod_mask_remove_consumed
Daniel Stone [Wed, 8 Aug 2012 12:26:23 +0000 (14:26 +0200)]
Add xkb_map_mod_mask_remove_consumed

A fairly simple helper which, given an xkb_mod_mask_t, removes all
modifiers which are consumed during processing of a particular key.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoAdd xkb_log_level enum rather than using syslog
Daniel Stone [Wed, 8 Aug 2012 12:01:46 +0000 (14:01 +0200)]
Add xkb_log_level enum rather than using syslog

Instead of relying on people including syslog.h, add our own
XKB_LOG_LEVEL_* defines.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoIncrease log verbosity in tests
Daniel Stone [Wed, 8 Aug 2012 11:56:28 +0000 (13:56 +0200)]
Increase log verbosity in tests

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoRules: mmap() rules file instead of using getc()
Daniel Stone [Fri, 3 Aug 2012 03:13:46 +0000 (05:13 +0200)]
Rules: mmap() rules file instead of using getc()

Good for a small performance win on my system.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoandroid: add build files
Pekka Paalanen [Mon, 14 May 2012 11:33:29 +0000 (14:33 +0300)]
android: add build files

squashed: android: set xkb config path

Conflicts:
Makefile.am

11 years agostringcomp: Make test more punishing
Daniel Stone [Fri, 3 Aug 2012 02:07:33 +0000 (04:07 +0200)]
stringcomp: Make test more punishing

Recreate the old test/dump scenario, where we test the following map:
  - rules: evdev
  - model: pc104
  - layout #1: us
  - layout #2: ru
  - layout #3: ca(multix)
  - layout #4: de(neo)

This is ever so slightly altered from the xkbcomp output; running the
following:
setxkbmap -rules evdev -model pc105 -layout us,ru,ca,de -variant
,,multix,neo -print | xkbcomp -xkb - -

will give you a map with RCTL added to the modifier_map for both Control
and Mod3.  Running the output through xkbcomp -xkb - - again, will give
you RCTL only added to Mod3.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agotest/dump: Remove superfluous test
Daniel Stone [Fri, 3 Aug 2012 02:02:31 +0000 (04:02 +0200)]
test/dump: Remove superfluous test

No longer necessary now we have stringcomp doing a full round-trip test
for us.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agotest/stringcomp: Perform full round-trip test
Daniel Stone [Fri, 3 Aug 2012 02:01:21 +0000 (04:01 +0200)]
test/stringcomp: Perform full round-trip test

We now pass! \o/

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agostringcomp: Remove unnecessary Level1 mappings
Daniel Stone [Fri, 3 Aug 2012 01:54:44 +0000 (03:54 +0200)]
stringcomp: Remove unnecessary Level1 mappings

As a map will implicitly go to level one unless explicitly mentioned
otherwise, remove all explicit =Level1 mappings, except for those with
preserve entries.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoAlways have at least one level in types
Daniel Stone [Wed, 8 Aug 2012 11:55:04 +0000 (13:55 +0200)]
Always have at least one level in types

The ONE_LEVEL definition from xkeyboard-config doesn't specify any
actual levels, but there's an implicit (anything unmatched) -> Level1
rule.  Given this, each type actually has at least one level, whether or
not it specifies anything.

Fixes stringcomp.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoIncludeStmt: Remove useless 'path' member
Daniel Stone [Fri, 3 Aug 2012 03:34:58 +0000 (05:34 +0200)]
IncludeStmt: Remove useless 'path' member

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoRemove unused vmodmask calculation
Daniel Stone [Fri, 3 Aug 2012 03:19:50 +0000 (05:19 +0200)]
Remove unused vmodmask calculation

This was basically an open-coded VModsToReal, which we were using in the
line immediately below.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agotest: Minimise includes
Daniel Stone [Fri, 3 Aug 2012 01:45:14 +0000 (03:45 +0200)]
test: Minimise includes

Mostly from functions which used to use file functions directly, but now
use test.h wrappers.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agostringcomp: Update input file for output changes
Daniel Stone [Fri, 3 Aug 2012 01:38:46 +0000 (03:38 +0200)]
stringcomp: Update input file for output changes

Bring the input file into line with recent changes to the dump output,
so we're as close as we can get to a round trip.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agotest: Add extremely rudimentary include path test
Daniel Stone [Fri, 3 Aug 2012 01:34:53 +0000 (03:34 +0200)]
test: Add extremely rudimentary include path test

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoRename xkey test to keysym
Daniel Stone [Fri, 3 Aug 2012 01:32:30 +0000 (03:32 +0200)]
Rename xkey test to keysym

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoPrint failed include paths on failure to find rules
Daniel Stone [Fri, 3 Aug 2012 01:22:48 +0000 (03:22 +0200)]
Print failed include paths on failure to find rules

Thus giving a hint as to which directory we're trying to find.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoMove xkb_context struct to xkb-priv.h
Daniel Stone [Fri, 3 Aug 2012 01:12:52 +0000 (03:12 +0200)]
Move xkb_context struct to xkb-priv.h

So we can print more intelligent debugging messages without needing
helper functions for the failed_includes array.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agocontext: Maintain list of failed include paths
Daniel Stone [Fri, 3 Aug 2012 01:11:19 +0000 (03:11 +0200)]
context: Maintain list of failed include paths

Keep around a list of paths we tried to add but couldn't.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoMore useful error message on failing RMLVO -> KcCGST
Daniel Stone [Fri, 3 Aug 2012 01:05:02 +0000 (03:05 +0200)]
More useful error message on failing RMLVO -> KcCGST

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoMove more of xkb_map_new_from_rmlvo into compilation
Daniel Stone [Fri, 3 Aug 2012 01:00:20 +0000 (03:00 +0200)]
Move more of xkb_map_new_from_rmlvo into compilation

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoStaticise xkb_map_new_from_kccgst
Daniel Stone [Fri, 3 Aug 2012 00:57:02 +0000 (02:57 +0200)]
Staticise xkb_map_new_from_kccgst

We didn't expose this to the outside world, and its only trivial user
was xkb_map_new_from_rules.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agotest: Use test_compile_*() in interactive
Daniel Stone [Fri, 3 Aug 2012 00:51:40 +0000 (02:51 +0200)]
test: Use test_compile_*() in interactive

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoAdd support for default rules/model/layout
Daniel Stone [Fri, 3 Aug 2012 00:51:10 +0000 (02:51 +0200)]
Add support for default rules/model/layout

Right now it just comes from build-time, but eventually this should be
sourced from configuration files at runtime too.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agotests: Fix uninitialised-use-of-'ret' warning
Daniel Stone [Fri, 3 Aug 2012 00:37:09 +0000 (02:37 +0200)]
tests: Fix uninitialised-use-of-'ret' warning

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agotest: Use test_get_context() in interactive
Daniel Stone [Fri, 3 Aug 2012 00:36:40 +0000 (02:36 +0200)]
test: Use test_get_context() in interactive

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoWarning fixes
Daniel Stone [Wed, 8 Aug 2012 11:30:05 +0000 (13:30 +0200)]
Warning fixes

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoAdd API to query whether a modifier is consumed
Ran Benita [Mon, 6 Aug 2012 21:20:40 +0000 (00:20 +0300)]
Add API to query whether a modifier is consumed

Currently the user has no way of knowing which of the active modifiers
have been used in the translation of a keycode to its keysyms. The use
case is described in the GTK docs: say there's a menu accelerator
activated by "<Alt>+". Some layouts have "+" shifted, and some have it
on the first level. So in keymaps where "+" is shifted, the Shift
modifier is consumed and must be ignored when the user is testing
for "<Alt>+". Otherwise, we may get "<Alt><Shift>+" and the accelerator
should not actually fire.

For this we also use the preserve[] information in the key types, which
can forces us to report modifiers as unconsumed even if they were used
in the translation. Until now we didn't do anything with this
information.

The API tries to match its surronding. It's not very efficient but this
can be fixed.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: remove default type
Ran Benita [Tue, 7 Aug 2012 10:23:44 +0000 (13:23 +0300)]
types: remove default type

The default type is copied over for each new key type to build on.
Further, it can be modified from within the xkb_types section itself,
with statements such as "type.modifiers = Lock" which affect all
subsequent type definitions.

The default type is (well, by default) just the simplest one level type
possible, with name "default". When no types are defined at all, it is
copied over to the keymap as the single type.

xkeyboard-config never changes the default type. There is also no sane
use case for doing so; changing any thing there doesn't make sense. So
instead of doing all the hard work of maintaining and copying this type,
which is practically never used, just remove it and initialize new types
appropriately.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: store atoms instead of strings for level and type names
Ran Benita [Tue, 7 Aug 2012 08:40:07 +0000 (11:40 +0300)]
types: store atoms instead of strings for level and type names

We don't use these strings much, so storing them in the manner they
were compiled saves some copying and space.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: use regular array for map entries
Ran Benita [Tue, 7 Aug 2012 05:52:23 +0000 (08:52 +0300)]
types: use regular array for map entries

This array is only initialized once.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: use regular array for types
Ran Benita [Tue, 7 Aug 2012 05:38:20 +0000 (08:38 +0300)]
types: use regular array for types

The current code doesn't resize it any more.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: remove DeleteLevel1MapEntries
Ran Benita [Tue, 7 Aug 2012 05:17:26 +0000 (08:17 +0300)]
types: remove DeleteLevel1MapEntries

If there is no map entry for some modifier combination, the default is
to use level 1. The removed code is an optimization to save some space
by removing these entries. But it doesn't actually save any space, and
did not in fact remove all level 1 entries (it walks the array while
modifying it so there's an off-by-one error).

We can instead keep them in the types but just not print them in
keymap-dump.c, to get about the same behavior.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: move preserve directly into xkb_kt_map_entry
Ran Benita [Mon, 6 Aug 2012 18:31:17 +0000 (21:31 +0300)]
types: move preserve directly into xkb_kt_map_entry

Currently each xkb_key_type has a preserve array, which is only allocated
if a preserve[] statement is specified in the type. In this case each map
entry has an element in the array.

The space savings are negligible; put this field where it logically
belongs.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoFix virtual modifiers mask extraction
Ran Benita [Sun, 5 Aug 2012 16:38:31 +0000 (19:38 +0300)]
Fix virtual modifiers mask extraction

The calculations were performed incorrectly in several places,
specifically shifting by 16 instead of 8 (= XkbNumModifiers) and masking
with 0xff instead of 0xffff.

More stuff that probably never worked as intended. This also makes these
more grep-able when we remove the vmods/real_mods separation.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: small changes
Ran Benita [Sun, 5 Aug 2012 11:05:03 +0000 (14:05 +0300)]
types: small changes

Just make things easier to follow, no functional changes.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoRemove xproto build dependency
Ran Benita [Wed, 1 Aug 2012 22:09:41 +0000 (01:09 +0300)]
Remove xproto build dependency

Very little left to do for this.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: don't use canonical/required types
Ran Benita [Wed, 1 Aug 2012 21:29:07 +0000 (00:29 +0300)]
types: don't use canonical/required types

Xkb required every keymap to have at least the four following canonical
types: ONE_LEVEL, TWO_LEVEL, ALPHABETIC, KEYPAD. This is specified in
e.g. the kbproto spec and XkbKeyTypesForCoreSymbols(3) man page.

If these types are not specified in the keymap, the code specifically
checks for them and adds them to the 4 first places in the types array,
such that they exist in every keymap. These are also the types (along
with some non-required 4-level ones) that are automatically assigned to
keys which do not explicitly declare a type (see FindAutomaticType in
symbols.c, this commit doesn't touch these heuristics, whcih are also not
very nice but necessary).

The xkeyboard-config does not rely on the builtin xkbcomp definitions of
these types and does specify them explicitly, in types/basic and
types/numpad, which are virtually always included.

This commit removes the special behavior:
- The code is ugly and makes keytypes.c harder to read.
- The code practically never gets run - everyone who uses
  xkeyboard-config or a keymap based upon it (i.e. everyone) doesn't need
  it. So it doesn't get tested.
- It mixes policy with implementation for not very good reasons, it
  seems mostly for default compatibility with X11 core.
- And of course we don't need to remain compatible with Xkb ABI neither.

Instead, if we read a keymap with no types specified at all, we simply
assign all keys a default one-level type (like ONE_LEVEL), and issue
plenty of warnings to make it clear (with verbosity >= 3). Note that
this default can actually be changed from within the keymap, by writing
something like
    type.modifier = Shift
    type.whatever_field = value
in the top level of the xkb_types section. (This functionality is
completely unused as well today, BTW, but makes some sense).

This change means that if someone writes a keymap from scratch and
doesn't add say ALPHABETIC, then something like <AE11> = { [ q Q ]; }; will
ignore the second level. But as stated above this should never happen.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: add a general overview
Ran Benita [Sun, 5 Aug 2012 10:46:56 +0000 (13:46 +0300)]
types: add a general overview

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: remove support for key behaviors
Ran Benita [Sat, 4 Aug 2012 07:47:56 +0000 (10:47 +0300)]
symbols: remove support for key behaviors

The possible key behaviors are:
KB_RadioGroup, KB_Overlay1, KB_Overlay2: already removed support for
these.
KB_Lock (with or without KB_Permanent): used to ignore key presses or
releases to simulate and deal with some legacy keyboard behaviors
(like keys that physically lock). Not used at all.

We already ignore them while processing key events in state.c, so make
it official.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: small changes
Ran Benita [Sun, 29 Jul 2012 08:39:44 +0000 (11:39 +0300)]
keycodes: small changes

to make it a bit nicer.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoHandle key names consistently
Ran Benita [Sat, 28 Jul 2012 19:15:59 +0000 (22:15 +0300)]
Handle key names consistently

We treat the key names as fixed length, non NUL terminated strings of
length XkbKeyNameLength, and use the appropriate *Text functions to
print them. We also use strncpy everywhere instead of memcpy to copy
the names, because it does some NUL padding and we might as well.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: add a general overview
Ran Benita [Sat, 28 Jul 2012 09:10:44 +0000 (12:10 +0300)]
keycodes: add a general overview

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: make ResolveLevel return zero-based level
Ran Benita [Sun, 5 Aug 2012 11:10:45 +0000 (14:10 +0300)]
expr: make ResolveLevel return zero-based level

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoAdd and use xkb_level_index_t
Ran Benita [Sun, 5 Aug 2012 16:24:44 +0000 (19:24 +0300)]
Add and use xkb_level_index_t

Several types are used over the code for shift levels; better to use
just one.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoaction: drop global actionInitialized
Ran Benita [Thu, 2 Aug 2012 21:20:07 +0000 (00:20 +0300)]
action: drop global actionInitialized

The action.c needs to use two constant Expr values, constTrue and
constFalse. To do this is keeps to static globals Expr's of type boolean
and the values "true" and "false" which need to be interned (and thus
context specific). The interning means they can't be made static const,
so there's a global flag and initializer function.

Instead of using this unsafe global state, we can simply use an integer
boolean expression (1 and 0) instead of a string one ("true" and
"false") and make them const.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: constify function arguments
Ran Benita [Thu, 2 Aug 2012 21:33:40 +0000 (00:33 +0300)]
expr: constify function arguments

We need this for later.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agolog: allow to resore default log function
Ran Benita [Mon, 6 Aug 2012 17:04:22 +0000 (20:04 +0300)]
log: allow to resore default log function

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agodarray: fix formatting
Ran Benita [Thu, 2 Aug 2012 14:59:57 +0000 (17:59 +0300)]
darray: fix formatting

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agofilecomp: fix path and error message
Ran Benita [Sun, 5 Aug 2012 09:03:51 +0000 (12:03 +0300)]
filecomp: fix path and error message

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agointeractive: add support to run from keymap file
Ran Benita [Thu, 2 Aug 2012 06:54:38 +0000 (09:54 +0300)]
interactive: add support to run from keymap file

This is useful for quickly testing a random keymap file. Use -k <PATH>.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeyseq: use our own keysyms
Ran Benita [Wed, 1 Aug 2012 21:40:22 +0000 (00:40 +0300)]
keyseq: use our own keysyms

Instead of <X11/keysym.h>

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoReplace more defines with enums
Ran Benita [Wed, 1 Aug 2012 19:12:13 +0000 (22:12 +0300)]
Replace more defines with enums

Mostly the ones used to track the fields of types/keys/leds which were
already defined.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoMake top level Handle*File functions nicer
Ran Benita [Wed, 1 Aug 2012 15:46:01 +0000 (18:46 +0300)]
Make top level Handle*File functions nicer

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoUse xkb_led_index_t throughout
Ran Benita [Sat, 28 Jul 2012 20:21:46 +0000 (23:21 +0300)]
Use xkb_led_index_t throughout

And use XKB_LED_INVALID instead of _LED_Unbound, which served the same
purpose here.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agovmod: remove unused fields
Ran Benita [Wed, 1 Aug 2012 18:31:36 +0000 (21:31 +0300)]
vmod: remove unused fields

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoREADME: s/xkb_desc/xkb_keymap
Ran Benita [Sat, 28 Jul 2012 20:31:08 +0000 (23:31 +0300)]
README: s/xkb_desc/xkb_keymap

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoUse only one set of core mod name-to-index functions
Ran Benita [Wed, 1 Aug 2012 08:25:34 +0000 (11:25 +0300)]
Use only one set of core mod name-to-index functions

These were repeated 5 times.

Note that this changes the ABI slightly: XKB_MOD_NAME_CAPS is changed
from "Caps Lock" to "Lock", which is the ordinary legacy mod name for
it. Since its hidden behind a #define, it's best to stay compatible with
the old names (as I think was intended, given that "Mod1", etc. are the
same).

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agomap: fix incorrect return value
Ran Benita [Wed, 1 Aug 2012 08:12:18 +0000 (11:12 +0300)]
map: fix incorrect return value

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agomap: fix virtual mod index calculation
Ran Benita [Wed, 1 Aug 2012 08:01:21 +0000 (11:01 +0300)]
map: fix virtual mod index calculation

The current code made us miss vmod index 0. Also look at the code in
vmod.c:LookupVModMask.

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