Commit Graph

851 Commits (95d4fb9e4bc815d39a974deaee5373254e134f93)

Author SHA1 Message Date
Ran Benita 95d4fb9e4b action: fix LookupEntry for "lockdevbtn"
xkbcomp has that bug as well, guess no one uses it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:31:12 +03:00
Ran Benita 7e0c49e084 action: remove redundant check
The NoAction handler always errors out with the same message.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:20 +03:00
Ran Benita 87bfd97333 action: keep array of default actions, instead of list of changes
The implementation of changing the default properties of actions, e.g. a
statements such as (from test/data/compat/basic):
    setMods.clearLocks= True;
    latchMods.clearLocks= True;
    latchMods.latchToLock= True;
works by keeping a list of ActionInfo's, each containing the neccesary
info from each statement, and then when some action comes up (e.g. in an
interpret statment) it goes through the list, and applies the relevent
ActionInfo's to the newly-constructed xkb_action.

Instead of doing this, we add a struct ActionsInfo, which contains an
array of xkb_actions, one for each type. When a default changing
statement appears, we change the action in the array; when a new action
comes up, we just copy from the array. This is simpler to figure out,
and pretty straightforward.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:20 +03:00
Ran Benita 4ca85c7b3b action: disallow setting an action_field default for all types
Currently where it is possible to write:
    setMods.clearLocks = True;
It's also possible to write:
    action.clearLocks = True;
This will set the default value for the clearLocks action field for
*all* action types, as opposed to just setMods in this case. If
subsequently an action is used for which this field does not make sense,
it will error out.
This doesn't make any sense, because any given field is only possible by at
most 3 or 4 action types... which you might as well write explicitly and
avoid the side effect mentioned above.
Needless to say this is one of xkbcomp's "hidden features" and is not
used anywhere; remove it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:20 +03:00
Ran Benita ba9f66bda3 action: clean up formatting of extern functions
Make it a bit easier to understand what they do.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:20 +03:00
Ran Benita 1736e7daad types: don't strdup a default name
None of the other files does that.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:20 +03:00
Ran Benita 149e1b2f0d types: use darray for KeyTypesInfo instead of list
Simpler, uses less memory and more efficient.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:19 +03:00
Ran Benita 8654d36e7a types: remove outdated comments
The code is pretty straightforward now...

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:19 +03:00
Ran Benita db639be6df keymap: optimize FindInterpsForKey a bit
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:25:19 +03:00
Ran Benita 872e15e52c keymap: refactor ApplyInterpsToKey
There's really not much to explain what the function used to do there...

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03 10:13:42 +03:00
Ran Benita 8c1b1b0e9e Add xkbcomp/keymap.c and move some code there
Add CompileKeymap to do most of what compile_keymap_file does now, and
move UpdateKeymapFromModifiers along with it from (mostly unrelated)
compat.c.
Also rename UpdateKeymapFromModifiers to UpdateDerivedKeymapFields,
because it does more than update the modifiers.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 591df1156d Move enum xkb_file_type to xkbcomp/ast.h
This is a more suitable place for this enum, since it's internal to
xkbcomp.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita efc2d74141 xkbcomp: clean up compile_keymap function
We make the xkb_file_type enum sequential instead of masks, and then
we don't have to repeat the file types several times in the function.
Makes the code cleaner.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 82491d5fd1 map, state: check for KeycodeInRange only in API functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 06d7803a6d state: fix mod_names_are_active
This function was always returning -1.
Adding a test, we see that test/state.c treat the is_active functions as
returning booleans, which would treat -1 as success, so we test for > 0
instead (most users would probably get this wrong as well...).
Also update the documentation for the are_active functions, and add a
ATTR_NULL_SENTINEL for gcc __attribute__((sentinel)).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 9f0c016063 state: fix type confusion within xkb_state_update_mask
idx should be xkb_mod_index_t, while mod is the mask.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita ae576e85b7 state: remove unneeded optimization
The code that follows does exactly that.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita a45b7d7559 state: light indicator when either condition is satisfied
For the indicator to be set, it is sufficient for at least one of the
group, modifier, or control state to match; this is in line with the
xkblib spec, section 8.2 and ComputeAutoState() in xserver/xkb/xkbLEDs.c
(though the xserver implementation differs from the spec on some
points...).

This also adds a tiny optimization to skip the entire check if the mask
is empty.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita d1b476a387 state: fix led_update_all group mask calculation
The one above uses which_mods, this one should use which_groups.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 9ba5ac0ec0 keycodes: remove outdated comments
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita bebad402e4 keycodes: use darray for aliases instead of list
Uses slightly more memory, but worth it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 518aff6d7b keycodes: use array for indicator names instead of list
Using a simple array here to mirror keymap->indicator_names makes much
more sense, and is simpler.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita be78b8264d keycodes: ignore "virtual" in indicators
The distinction between real/virtual indicators is useless for us, we
can just ignore it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
Ran Benita 4c56d4d9c0 symbols: call deinit functions Clear instead of Free
Everywhere else Free is reserved for when the argument is free'd as
well.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02 19:17:09 +03:00
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