This is a regression introduced in ed78fbcb30.
XKB_STATE_EFFECTIVE is just a OR of the other states, so using & here is
completely wrong. So test/state shows for example:
dumping state for LCtrl down:
group English (US) (0): effective depressed latched locked
mod Control (2): depressed latched locked
dumping state for LCtrl + RAlt down:
group English (US) (0): effective depressed latched locked
mod Control (2): depressed latched locked
mod Mod1 (3): depressed latched locked
dumping state for RAlt down:
group English (US) (0): effective depressed latched locked
mod Mod1 (3): depressed latched locked
dumping state for Caps Lock:
group English (US) (0): effective depressed latched locked
mod Lock (1): depressed latched locked
led Caps Lock (0): active
dumping state for Alt-Shift-+
group English (US) (0): effective depressed latched locked
mod Shift (0): depressed latched locked
mod Mod1 (3): depressed latched locked
which is bogus.
Signed-off-by: Ran Benita <ran234@gmail.com>
This rule allows you to put several xkb_keymaps in one file.
This doesn't make any sense: only the default/first can ever be used,
yet the others are fully parsed as well.
Different keymaps should just be put in different files.
Signed-off-by: Ran Benita <ran234@gmail.com>
This is a proof-of-concept for the long key names. The keycodes in the
file evdev-xkbcommon are autogenerated from linux/input.h, and uses the
names given there; all of the previous names are aliased to the new
names, so they continue to work with the symbols files, etc.
You can try it with 'sudo ./test/interactive -r evdev-xkbcommon -n 0'
The -n 0 means that we don't offset the evdev scan codes - just feed
them directly. The -r evdev-xkbcommon just means to use a new rules file
which makes us use the new keycodes file. (The only problem I can see is
with the MENU and LSGT names which has some conflicts).
Maybe some day xkeyboard-config could ship something similar, so that
the 8 offset is unneeded.
Signed-off-by: Ran Benita <ran234@gmail.com>
This function really needs a format argument, for symmetry with the
keymap creation functions. If we add new formats, we will almost
certainly want to add support for serializing it into a string. It would
also allow to convert from one format to another, etc.
The in the common case, the user would just want to use the format she
used to create the keymap; for that we add a special
XKB_KEYMAP_USE_ORIGINAL_FORMAT value, which will do that (it is defined
to -1 outside of the enum because I have a feeling we might want to use
0 for something else). To support this we need to keep the format inside
the keymap. While we're at it we also initialize keymap flags properly.
This changes the API, but the old xkb_map_get_as_string name works as
expected so this is the best time to do this.
Signed-off-by: Ran Benita <ran234@gmail.com>
This is to follow the general scheme set by all of the other API
functions.
Since no one is using these functions yet, we don't (actually better
not) add the old names to xkbcommon-compat.h.
Signed-off-by: Ran Benita <ran234@gmail.com>
These values weren't wrapped before, which caused group_index_is_active
to stop working after a few group switches.
Also, the current group-wrapping function didn't take into consideration
actions such as LockGroup=-1, which need to wrap around, etc.
xkb_layout_index_t is unsigned, but it was used to hold possibly
negative values (e.g. locked_group is 0 and gets a -1 action).
This group wrapping function should now act like the XkbAdjustGroup
function from xserver, and at least ./test/interactive doesn't bring up
any problems with group switching any more.
Signed-off-by: Ran Benita <ran234@gmail.com>
This old rules parser gives the same kccgst here, so in the interest of
staying compatible we shouldn't fix it there. Similarly we shouldn't
touch ParseIncludeMap, so this is the best place to handle this.
Signed-off-by: Ran Benita <ran234@gmail.com>
This just prints the compiled keymap string for to the given command
line arguments. This often useful when developing.
Signed-off-by: Ran Benita <ran234@gmail.com>
Trying ''./test/interactive -l us:5' causes us to crash.
The <layout>:<N> syntax says to put this layout at the N'th level.
However the code (inherited from xkbcomp) doesn't check that the group
is valid, and then happily indexes keyi->groups with it, which has a
static size of XKB_NUM_GROUPS (the SetExplicitGroup function assumes the
index is valid). So any value a user might put there > 4 makes nice
things happen.
Signed-off-by: Ran Benita <ran234@gmail.com>
e.g. hhhhhHHHHHHHhhhhhh with shift down and up in the middle.
Unfortunately trying a quick test with test/interactive is not possible
because the evdev soft-repeat stops the repeat when another key is
pressed. So you need real soft-repeat for that.
Signed-off-by: Ran Benita <ran234@gmail.com>
- Add context.h and move context-related functions from xkb-priv.h to
it.
- Move xkb_context definition back to context.c.
- Add keysym.h and move keysym upper/lower/keypad from xkb-priv.h to it.
- Rename xkb-priv.h to map.h since it only contains keymap-related
definitions and declarations now.
- Remove unnecessary includes and some and some other small cleanups.
Signed-off-by: Ran Benita <ran234@gmail.com>
These statements are pretty pointless for us; we don't restrict keycodes
like X does, and if someone writes e.g. maximum = 255 but only has 100
keys, we currently happily alloc all those empty keys. xkbcomp already
handles the case when these statements aren't given, and uses a computed
min/max instead. We should just always use that.
(Of course since keycodes/evdev currently uses almost all of the
keycodes in the range it declares, including 255, this doesn't save any
memory for the common user right now).
Signed-off-by: Ran Benita <ran234@gmail.com>
This layout stretches us pretty well, so it's good for testing nothing
breaks. There are a couple of things that need looking into, though
(particularly the level5 issue).
Signed-off-by: Ran Benita <ran234@gmail.com>
Background:
The CopySymbolsDef has a comment on a couple of lines which supposedly
fixed a bug:
/*
* kt_index[i] may have been set by a previous run (if we have two
* layouts specified). Let's not overwrite it with the ONE_LEVEL
* default group if we dont even have keys for this group anyway.
*
* FIXME: There should be a better fix for this.
*/
if (!darray_empty(groupi->levels))
key->kt_index[i] = types[i];
But neither the comment nor the fix make any sense, because the kt_index
is indexed per group, i.e. each group gets its own type.
The original xkbcomp commit which added this (36fecff58) points to this
bug: https://bugzilla.redhat.com/show_bug.cgi?id=436626
which complains about -layout "ru,us" -variant "phonetic," not working
properly. And indeed when we try:
sudo ./test/interactive -l ru,us -v
the first group doesn't get any syms for the main keys.
The problem (Clearly the fix above is useless):
The ru(phonetic) map is specified using aliases, e.g. LatQ, LatW instead
of AD01, AD02, etc. When combined with another layout which uses the
real names (AD01, AD02), the symbols code should recognize they are the
same key and merge them into one KeyInfo. The current code does that,
but it doesn't catch the case where the alias was processes *before* the
real one; so we get two KeyInfo's and the later one wins. So e.g. the
ru(phonetic) symbols are ignored.
The fix:
Before adding a new KeyInfo to the keys array, always replace its name
by the real name, which avoids the entire issue. Luckily this is done
pretty late so most error messages should still show the alias name.
Signed-off-by: Ran Benita <ran234@gmail.com>
With Dan Nicholson's permission (via email), update his copyright and
license statements to the standard X.Org boilerplate MIT license, as
both myself and Ran have been using.
Clean up my copyright declarations (in some cases to correct ownership),
and add copyright/license statements from myself and/or Ran where
appropriate.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
There are two ways to separate multiple files in XKB include statements:
'+' will cause the later file to override the first in case of conflict,
while '|' will cause it augment it (this is done by xkbcomp). '!' is
unrelated here.
Since '|' is practically never used, this wasn't noticed.
In the modified test, the '|some_compat' previously was just ignored.
Signed-off-by: Ran Benita <ran234@gmail.com>
Avoids a warning, from xkeyboard-config:
commit 6676053f2c93596c2aaa9905151a5c76355a1540
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri Jun 29 09:53:45 2012 +1000
symbols: keypad can only have one default section
Warning: Multiple default components in keypad
Using x11, ignoring pointerkeys
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Ran Benita <ran234@gmail.com>
This way the test logs have all the information, but we don't get eye
bleed every time we run them manually. One can always use
TESTS_ENVIRONMENT (we correctly use AM_TESTS_ENVIRONMENT now), or set
the envvars from the shell.
Signed-off-by: Ran Benita <ran234@gmail.com>
Now that we don't use syslog, "level" does sound more commonplace. We
should change it while there is still nobody using it.
Also leave some space between the integers of the xkb_log_level enum
values, if we ever need to shove more in between.
Signed-off-by: Ran Benita <ran234@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>