Commit Graph

1277 Commits (109fe7059c6d520ac70c744b319a795af7ba112c)

Author SHA1 Message Date
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
Ran Benita 5d9a5cb003 Commit and distribute ks_tables.h
The ks_tables.h file is generated by makekeys.py from
xkbcommon-keysyms.h, which in turn is generated initially by 'make
update-keysyms'. The xkbcommon-keysyms.h file is commited to git and
distributed in the tarball. Since ks_tables.h should only ever change
when xkbcommon-keysyms.h changes, it is more sensible to update them
together and treat them the same, instead of generating ks_tables.h
every time for every builder with 'make', as we do now.

This means we don't need python as a build dependency (only the one
running update-keysyms, i.e. no one, needs this), and we can be
sure exactly the same file is used by everyone. We also don't need to
run makekeys.py on every build.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-17 20:09:09 +02:00
Ran Benita 179855116d utils: add and use ARRAY_SIZE macro
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-16 21:31:25 +02:00
David Herrmann 7b3bd11f92 Add xkb_keysym_from_name() flags argument for case-insensitive search
This adds a flags argument to xkb_keysym_from_name() so we can perform a
case-insensitive search. This should really be supported as many keysyms
have really weird capitalization-rules.

However, as this may produce conflicts, users must be warned to only use
this for fallback paths or error-recovery. This is also the reason why the
internal XKB parsers still use the case-sensitive search.

This also adds some test-cases so the expected results are really
produced. The binary-size does _not_ change with this patch. However,
case-sensitive search may be slightly slower with this patch. But this is
barely measurable.

[ran: use bool instead of int for icase, add a recommendation to the
doc, and test a couple "thorny" cases.]

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-16 21:29:09 +02:00
Ran Benita 5fff637e07 makekeys: replace helper with python script and binary search
This removes the complicated and undocumented hash-table creation-helper
and replaces it with an autogenerated sorted array. The search uses simple
bsearch() now.

We also tried using gperf but it turned out to generate way to big
hashtables and when reducing the size it isn't really faster than
bsearch() anymore.

There are no users complaining about the speed of keysym lookups and we
have no benchmarks that tell that we are horribly slow. Hence, we can
safely use the simpler approach and drop all that old code.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-16 21:10:04 +02:00
Ran Benita 3477d9e448 Finish first round of API documentation
There are a few @todo's, but nothing serious.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-13 14:03:29 +02:00
Ran Benita f43b33c02f state: make mod_index_is_consumed() return -1 on invalid input
Like all the other functions.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-13 13:13:55 +02:00
Ran Benita 523e46f41a Change log env vars to XKB_LOG_LEVEL/VERBOSITY
A bit more consistent and descriptive.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-12 10:17:57 +02:00
Ran Benita bde066b920 doc: use JAVADOC_AUTOBRIEF
Don't have to type @brief all the time.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 21:51:08 +02:00
Ran Benita 89523789ca ast: simplify AppendStmt
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 21:51:08 +02:00
Ran Benita bbf388ec1f Make xkb_keymap_num_leds return the index range instead of active count
Currently xkb_keymap_num_leds() returns a count of valid (settable)
leds. Because the indexes might be non-consecutive, and some leds
might not be settable, it is incorrect to use this function for
iterating over the leds in the keymap. But this is the main use case of
this function, so instead of the current behavior we adapt the function
to the use case by making it return the needed range of iteration.
The caller needs to handle invalid intermittent indexes, though.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 16:54:17 +02:00
Ran Benita b6ddd10568 keymap: rename keymap->sym_interpret -> sym_interprets
This can be a bit confusing.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 14:05:49 +02:00
Ran Benita e43f53a698 compat: add documentation for interpret's
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 14:03:03 +02:00
Ran Benita 90b1984cba compat: don't forget to copy XKB_MATCH_NONE interpret's
Commit a8d462e366 accidentally removed the
OR with XKB_MATCH_NONE. It is in fact unused though.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11 12:10:26 +02:00
Ran Benita a86fa17aeb build: change to AM_MAINTAINER_MODE([enable])
Disabled maintainer mode is annoying, we have no reason to do it. The
old behavior can still be had with --disable-maintainer-mode.
See:
http://lists.x.org/archives/xorg-devel/2012-September/033757.html
http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/maintainer_002dmode.html

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 21:01:15 +02:00
Ran Benita 2c188833c6 build: honor $NOCONFIGURE in autogen.sh
Using NOCONFIGURE=1 ./autogen.sh can prevent it from running ./configure
on its own, which is sometimes useful.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 21:00:36 +02:00
Ran Benita a05fbc17c5 stringcomp: test compilation of a dump of a keymap created from rules
This would have caught the regression fixed in 2ac319c.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 19:44:23 +02:00
Ran Benita 9197eb0fb3 Remove the XKB_NUM_INDICATORS limit
Use a darray instead of a static array of size 32.
We still enforce XKB_MAX_LEDS because of the size of xkb_led_mask_t.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 19:44:23 +02:00
Ran Benita f3732d8349 keymap: don't use darray for keymap->keys
It's never resized.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 17:51:06 +02:00
Ran Benita bdea377c93 Rename XKB_NUM_GROUPS to XKB_MAX_GROUPS
This is a more appropriate name now.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 17:30:15 +02:00
Ran Benita 1dbb2c4a9a keycodes: refactor AddIndicatorName
Make it shorter and fix the XXX.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 12:25:23 +02:00
Ran Benita 2f4db8a95b keymap, state: don't assume led index < xkb_keymap_num_leds
xkb_keymap_num_leds() returns the number of leds that have any
possibility of being set. Even if a led is defined but can not be set in
any way, it is not counted.

In a few places currently we assume that led indexes are smaller than
this number, which is wrong both for the above reason and for the fact
that the xkb format actually allows explicitly setting the indicator
index, which means that the indexes might be non-consecutive.

We don't really have good API to iterate on leds, now, because
xkb_keymap_num_leds is pretty useless. To work around that we use
sizeof(xkb_led_mask_t) * 8.

This makes the "Group 2" led work (try switching to a layout other than
the first in test/interactive).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10 10:10:45 +02:00