Commit Graph

1298 Commits (27e20662292688639a3a141c843b99e12fc7fe11)

Author SHA1 Message Date
Ran Benita 089c3a1811 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:
acdad6058d
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>
2013-03-18 22:20:01 +00:00
Ran Benita 0ad8bf573f test/interactive: also print the level
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:01 +00:00
Ran Benita bc7b2ff2fb 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>
2013-03-18 22:20:01 +00:00
Ran Benita 4058110676 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>
2013-03-18 22:20:01 +00:00
Ran Benita 3d731eba5c 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.]
2012-12-13 14:02:12 +00:00
Daniel Stone bb620df7aa 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>
2012-12-06 15:04:15 +11:00
Ran Benita f159846943 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>
2012-11-11 16:14:30 +02:00
Ran Benita 7372c9f181 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>
2012-11-11 16:09:05 +02:00
Ran Benita 60bd92021b 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>
2012-11-11 00:32:16 +02:00
Daniel Stone 324d4dbd99 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>
2012-11-09 14:26:49 +11:00
Ran Benita 577612258a 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>
2012-11-07 18:59:41 +02:00
Ran Benita d87035adac 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>
2012-11-07 18:59:41 +02:00
Ran Benita eea0eaebfa doc: clarify that keysym_to_utf8 returns size including '\0'
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-11-06 23:01:44 +02:00
Ran Benita d9317d5f32 keysym-utf: mark keysymtab array as static
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-11-05 21:50:38 +02:00
Ran Benita 7891c9170b 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>
2012-11-05 21:34:59 +02:00
Ran Benita fb201645b2 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>
2012-11-04 16:14:47 +02:00
Ran Benita 998c957a3c 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>
2012-10-30 18:25:08 +02:00
Damien Lespiau 860fb171a9 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>
2012-10-30 15:08:14 +02:00
Damien Lespiau 2f7385d0e0 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>
2012-10-30 15:08:14 +02:00
Ran Benita 94155878ec test/keyseq: add test for setting depressed group
Tests the SetGroup action is working properly.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-29 20:20:51 +02:00
Ran Benita 7261f404d2 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>
2012-10-29 01:20:04 +02:00
Ran Benita a51ee70419 state: don't use xkb_keymap_num_layouts internally
Clearer and more greppable this way.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-26 16:34:39 +02:00
Ran Benita b935d3610f doc: fix wrong comment
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-26 16:16:18 +02:00
Ran Benita ee6f3f2809 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>
2012-10-26 16:12:28 +02:00
Ran Benita 92360016fe 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>
2012-10-26 15:09:57 +02:00
Ran Benita 22b868fd75 Makefile.am: split sed script into multiple lines
To make it visible on one screen.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-26 15:09:54 +02:00
Ran Benita 0a5e9d90e7 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>
2012-10-26 14:43:15 +02:00
Ran Benita a851ef1ed9 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>
2012-10-26 14:25:17 +02:00
Ran Benita c1c1b720b0 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>
2012-10-24 23:27:40 +02:00
Ran Benita 6f093ad56b 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>
2012-10-24 23:09:26 +02:00
Daniel Stone a35d322322 More README
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-10-24 17:38:28 +11:00
Daniel Stone 202f560691 README updates
Good thing I didn't check this before I made a release.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-10-24 17:00:24 +11:00
Daniel Stone 5be22ad641 Bump to 0.2.0
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-10-24 03:13:46 +11:00
Ran Benita 3eac759989 doc: various fixes
Just moving around / fixing syntax / grammar.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-23 17:22:13 +02:00
Ran Benita 33bba36821 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>
2012-10-23 17:22:13 +02:00
Ran Benita e24ed49c72 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>
2012-10-23 17:22:13 +02:00
Ran Benita f76859bc87 keymap: use plain array for keymap->group_names
Again it is not resized.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-23 17:22:13 +02:00
Ran Benita 867992cd21 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>
2012-10-23 17:22:13 +02:00
Daniel Stone 6bc9480ad1 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>
2012-10-24 00:59:37 +11:00
Ran Benita 0c98237f02 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>
2012-10-22 22:23:29 +02:00
Ran Benita a807494e47 test/interactive: add option to show state changes
Pass -c to see.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-22 22:23:29 +02:00
Ran Benita 4b81c9f3e3 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>
2012-10-22 21:58:03 +02:00
Ran Benita 550cb24d3c 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>
2012-10-22 21:55:43 +02:00
Ran Benita 6a94b122a4 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>
2012-10-22 21:48:40 +02:00
Ran Benita 3a5f87b8e9 doc: add note about X11 vs. extended keycodes
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-22 17:53:44 +02:00
Ran Benita 0779d9dcad Silence a couple of warnings
These appear to come and go randomly.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-21 17:13:25 +02:00
Ran Benita bb82759c90 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>
2012-10-18 23:12:24 +02:00
Ran Benita e6946ae2c5 Remove a couple more uses of static char buffers
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-18 22:55:17 +02:00
Ran Benita 714e95e144 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>
2012-10-18 22:51:10 +02:00
Ran Benita eb748ab643 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>
2012-10-18 21:04:27 +02:00