Commit Graph

827 Commits (2eba51c0f603535dc2663f2666437305b287efb3)

Author SHA1 Message Date
Ran Benita 2eba51c0f6 symbols: remove comparison of unsigned >= 0
clang warning.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 3d305bd0cb vmod: remove outdated comments
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita b3aced7e22 vmod: ClearVModInfo doesn't need the keymap
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita ab1566cd6b vmod: remove useless keymap initialization
keymap->vmods is not touched until UpdateModifiersFromCompat,
where it initialized and used.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita f410622b4b vmod: remove support for resolving integer to virtual modifier
This is only relevant to the virtualModifier= statement in interpret
statements in xkb_compat. The current code allows to write e.g.
    virtualModifier = 4
to get the virtual modifier whose index happens to be 4 (possibly
declared in other files or sections, i.e. xkb_types). Doing this is
undeterministic, will break without notice, and not used anywhere.
Don't allow it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita d3ddcf70e8 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>
2012-09-02 19:17:09 +03:00
Ran Benita b9c87eb710 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>
2012-09-02 19:17:09 +03:00
Ran Benita eaa50c450b xkbcomp: seperate keymap-copying code from Compile functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 6738d30036 compat: only compute 'bool report' once
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:08 +03:00
Ran Benita e5fdbcbb99 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>
2012-09-02 18:53:01 +03:00
Ran Benita c9466b32df compat: use darray instead of list for interps
No need for a list here.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 18:53:01 +03:00
Ran Benita 8c6694fd58 compat: remove "flags" field from xkb_indicator_map
We don't set this field any more.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 18:52:46 +03:00
Ran Benita 6e676cb7d8 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>
2012-09-01 10:59:47 +03:00
Ran Benita d573600da0 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>
2012-09-01 10:59:47 +03:00
Ran Benita 9de067aad4 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>
2012-09-01 10:59:47 +03:00
Ran Benita 7f75502f18 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>
2012-09-01 10:59:47 +03:00
Ran Benita 02de2a3e74 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>
2012-09-01 10:59:46 +03:00
Ran Benita 65c4a71731 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>
2012-09-01 10:59:46 +03:00
Ran Benita 16f2de8bf0 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>
2012-09-01 10:59:46 +03:00
Ran Benita e9aa84f311 compat: small changes
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-01 10:59:46 +03:00
Ran Benita 4fec91cbbc compat: add general overview
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-01 10:59:46 +03:00
Ran Benita 79a2cc09cc 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>
2012-09-01 10:59:46 +03:00
Ran Benita 8f1ee62904 types: add "Effects on keymap" to overview
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-01 10:59:46 +03:00
Ran Benita 7ef359def1 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>
2012-09-01 10:58:10 +03:00
Ran Benita cdc228eaf6 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>
2012-09-01 10:58:10 +03:00
Ran Benita 3634b1565e 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>
2012-09-01 10:58:10 +03:00
Ran Benita e535352828 Move ISEMPTY to utils.h
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-01 10:58:10 +03:00
Daniel Stone f491285a5f 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>
2012-08-11 18:17:00 +02:00
Ran Benita ec2172f31b Combine a couple of macros
Easier to see what it does without the trivial macros.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-10 22:49:46 +03:00
Ran Benita 4c34bda15a 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>
2012-08-10 22:42:17 +03:00
Ran Benita 600caac33a 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>
2012-08-10 22:06:12 +03:00
Ran Benita 87dff888ab Store actions inside struct xkb_key
Cuts out a lot of useless redirection and space.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-10 21:54:33 +03:00
Ran Benita 7bcc5fabbd 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>
2012-08-10 13:49:20 +03:00
Ran Benita 0cc5ae33b5 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>
2012-08-10 13:49:20 +03:00
Ran Benita f7c9d749d3 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>
2012-08-10 13:49:20 +03:00
Ran Benita 34e690ceeb 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>
2012-08-10 13:49:20 +03:00
Ran Benita ef518a10af 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>
2012-08-10 13:49:19 +03:00
Ran Benita 75853ed66b 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>
2012-08-10 13:45:58 +03:00
Ran Benita 6d61e39d20 state: use global static const for fake action
Requires constifying some arguments.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-10 13:45:58 +03:00
Ran Benita 07b18bde17 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>
2012-08-10 13:45:58 +03:00
Ran Benita 45cd92b4d3 Fix xkb_keymap::vmods type
It maps a vmod to a mask, of course.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-09 02:33:51 +03:00
Ran Benita 41478b4309 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>
2012-08-09 01:57:17 +03:00
Ran Benita fafc1132d2 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>
2012-08-09 01:57:11 +03:00
Ran Benita 0f1ca360f1 keymap-dump: use VModMaskText
The difference between the two are irrelevant here.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-09 01:55:59 +03:00
Ran Benita 5a51ce8b36 Fix warning
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-09 01:55:30 +03:00
Daniel Stone 2f1f1bca5b 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>
2012-08-08 16:23:31 +02:00
Daniel Stone 5e276adb92 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>
2012-08-08 16:23:31 +02:00
Daniel Stone ba8458a9fd Increase log verbosity in tests
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08 16:23:31 +02:00
Daniel Stone d5f725f69a 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>
2012-08-08 16:23:31 +02:00
Pekka Paalanen 3199ea7383 android: add build files
squashed: android: set xkb config path

Conflicts:
	Makefile.am
2012-08-08 16:23:31 +02:00