Commit Graph

2206 Commits (bc330c00e66b237a683ed2c5421233a774faa923)

Author SHA1 Message Date
Kristian Høgsberg 47d3b3969b Drop CARD32 and Opaque types 2010-06-28 06:50:12 -04:00
Daniel Stone 2fb329c964 Copy and duplicate XkbModsRec and XkbKTMapEntryRec
Copy these types in so we can extend the vmod size.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-23 16:25:10 +01:00
Daniel Stone b74223eb50 fix mod size confusion
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-23 16:25:02 +01:00
Daniel Stone 8693c2652c Add really rudimentary rules caching support
Keep the parsed form of the last-used rules file around, and reuse that
if we get asked for the same ruleset.  If not, bin it and cache the
other one.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:57:16 +01:00
Daniel Stone 7257d4c89e Use CARD32 instead of Atom, move geom headers in
Use CARD32 instead of Atom/KeySym/et al to avoid type size confusion
between server and non-server code; relatedly, move the geometry headers
in from kbproto, so every non-simple type (i.e. structs containing
nothing more than basic types) is now copied into xkbcommon.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:57:16 +01:00
Daniel Stone b38525421f Interp: More lazy keysym resolution
Resolve the keysyms when we create an InterpDef, rather than directly
in the parser.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:57:16 +01:00
Daniel Stone 2c4a045aca Allow external atom databases
Allow people to plug in an external atom database (e.g. the X server's),
so we don't have to migrate our own atoms over later.  We are a bit
over-keen on atoms at the moment, so it does pollute the atom database a
bit though.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:57:16 +01:00
Daniel Stone 15b0db5492 Copy in XkbCompatMapRec and XkbSymInterpretRec
These contain actions, so transition them ahead to XkbcAction and move
them into XKBcommon.h.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:57:16 +01:00
Daniel Stone 60e7eeeba1 Use CARD32 instead of Atom, drag in XkbClientMapRec
On 64-bit architectures, XID varies in size between the server (always
32 bits), and non-server (always unsigned long) for some inexplicable
reason.  Use CARD32 instead to avoid this horrible trap.

This involves dragging in XkbClientMapRec so we don't get stuck in the
KeySym trap.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:57:12 +01:00
Daniel Stone d2d787df65 Regroup actions into current vs. deprecated, resize vmod
Use Xkbc* for all our actions that we intend to keep around, and Xkb*
for deprecated ones we can hopefully get rid of, at least internally.

While we're at it, make vmods be a uint32_t.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone e564235b43 xkbcomp: Don't malloc() and free() most scanned tokens
Use a constant buffer instead.  Sigh.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone f246db20f4 Fix compilation with DEBUG
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone acc467de9f xkbcomp: Use fread() instead of getc()
So, it turns out that if you're parsing a fairly large amount of data,
using getc() to get all the input rather than, say, read(), is some kind
of remarkably daft and unperformant idea.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone 240a0c3409 xkbcomp: Lazy keysym parsing (avoid XStringToKeysym)
Instead of calling XStringToKeysym on every keysym we parse, store it as
a string until we need to store it in an actual keymap.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone 48baabeb38 Atoms: Avoid allocations in XkbAtomText()
XkbAtomGetString() returns a freshly-allocated string, whereas
XkbAtomText() returns the same in a temporary buffer.  XkbAtomText used
to call XkbAtomGetString() and then free the result, which seems quite
spectacularly pointless when you think about it.  Shuffle the atom code
around so we don't have to allocate for XkbAtomText().

This changes semantics slightly wrt non-printable characters, but I
haven't been able to see any effect so far.  And it may well be ever so
slightly quicker.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone 080a083fd2 configure.ac: Enable automake silent rules by default
This allows us to spot warnings much more easily.  Also, drop the
now-deprecated AM_MAINTAINER_MODE.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone a0e180b083 Expose tbGetBuffer to the rest of libxkbcommon
This will let us implement XkbAtomGetString on top of XkbAtomText,
instead of having the latter get a duplicated string, dump it into a
temporary buffer, and subsequently free it (sigh).

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone 4346e0065b xkbcomp: keycodes: Silence gcc warnings
It was right to warn us: some of these were actually bogus.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone 5df3dff741 xkbcomp: geometry: Plug numerous atom text & expr leaks
This code is absolute misery.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone 18039a6c0b xkbcomp: Atom text and expr leak fixes part #973
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone a22386d402 xkbcomp: Don't leak atom text and string exprs, again
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:56 +01:00
Daniel Stone 8904c6eea7 xkbcomp: expr: Use XkbcAtomText instead of GetString
This returns us a temporary string, rather than leaking the atom.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone ad0a3d7c52 xkbcomp: Don't leak atom text and string exprs
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone d20bdd3b9a xkbcomp: vmod: Don't get and immediately intern atoms
XkbcInternAtom(XkbcAtomGetString(atom)) has to be the most spectacularly
broken antipattern I've yet seen.  Just compare the atoms directly.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone 50a037cacf xkbcomp: Replace open-coded strdup
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone 5140250273 Add testcase for XkbcCanonicaliseComponents
Should be reasonably thorough; the shell part is, however, quite
unpleasant.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone 85b7f47d8a Add XkbcCanonicaliseComponents
Canonicalises two sets of components (new and old), e.g.:
new: +bar
old: foo
result: foo+bar

This is required as part of the spec, so clients can reuse part of the
device's old keymap.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone 8ffa371395 XKBcommon.h: Make header self-contained
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone 8b5af79b7b Keysym: Add apallingly bad API documentation for keysym <-> string
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone 70b64213ca Make keysym <-> string conversion public API
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone 62eb167d56 XKB: Text: Use keysym <-> string conversion from keysym.c
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone a8bb86a48a Test: Keysym: Add tests for new keysym <-> string conversions
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:55 +01:00
Daniel Stone cdc735c8ca Keysym: Fix conversion for Unicode and bare numbers
Ensure that Unicode string representations are accepted and turned into
numbers, as well as hexadecimal numbers in 0xabcd1234 form; unknown
keysyms are output as 0xabcd1234 in string form.

This also ensures that strings are never returned malloc()ed.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2010-06-22 15:56:50 +01:00
Daniel Stone 8e3239a78f KeySym: Actually handle NoSymbol
Add NoSymbol into the keysym table, so keysym <-> string conversion works for
that, too; also eliminate special-casing of VoidSymbol.

This will require special-casing in libX11 to preserve its API.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-04-25 14:56:57 +10:00
Daniel Stone a5ce9754dc test: Fix srcdir != objdir build and test failures
filecomp would fail because it couldn't find the input files, after
compilation failed due to missing includes.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2009-04-25 14:56:47 +10:00
Dan Nicholson 4e854a21aa listing: Drop unused deviceSpec argument
The server might care about this, but ListComponents is just reading xkb
files.
2009-04-21 23:22:25 -07:00
Dan Nicholson 481deea178 xkbcomp: Another fairly major rewrite of the listing mode
The listing code in xkbcomp had been setup to allocate a set of buffers
with file paths and then later parse through them to find which maps were
needed.

All the allocation (with the additional allocation for the components
list) was making it really slow, so this patch makes everything simpler
by just generating the components list as we walk the directory tree.
2009-04-21 06:16:15 -07:00
Dan Nicholson 18b43f8dfe Rewrite listing code to generate XkbComponentListPtr
In xkbcomp, the listing code printed out the xkb files to stdout and the
caller would parse the output. Here, we can just generate a
XkbComponentListPtr and pass it back.

This should be a series of smaller commits, but there was no clean way to
do it since it's basically a complete rewrite except for the core map
matching logic.

A lot of code used for special printing modes in xkbcomp has been
shedded. Callers can massage the output as they please.
2009-04-19 16:34:12 -07:00
Dan Nicholson 559305a5cb xkbcomp: Kill unused listing code and make functions static
Much of this was only called from xkbcomp and not used to generate
listings for the server.
2009-04-16 21:47:28 -07:00
Dan Nicholson 5983a4e69d Scale back global variables
Some of the global variables were either not used anymore or only used
in the listing code.
2009-04-16 20:01:13 -07:00
Dan Nicholson 9520ea0eb3 Add XkbNameMatchesPattern implementation from xkbfile
The xkbcomp listing code matches a glob type pattern against installed
xkb files. This adds a Xkbc implementation of the pattern matching code.
2009-04-13 06:24:36 -07:00
Dan Nicholson fa183ce354 xkbcomp: Fix use of removed macros 2009-04-13 06:24:36 -07:00
Dan Nicholson 3d4c4d06d5 Revert "xkbcomp: Remove listing sources"
This reverts commit c4c9e36fbf. It turns
out that the listing code is used to support the X_kbListComponents
request (via XkbListComponents).

This will have to be refactored into some reasonable interface instead
of the current usage where the server reads xkbcomp stdout. Gross.
2009-04-13 06:24:36 -07:00
Dan Nicholson 3dee8ac999 misc: Coding-style cleanup 2009-04-13 06:24:29 -07:00
Dan Nicholson 53ead9b575 Use xkbpath API for locating rules
Instead of hardcoding the XKB base directory when searching for rules in
the xkbcomp code, we can extend the xkbpath API to cover rules and reuse
it. That will make it more convenient if it's ever exposed so people can
set their XKB search paths in a reasonable way.
2009-04-11 10:39:55 -07:00
Dan Nicholson c728d91bde Program and files for testing CompileKeymapFromFile
A few simple test cases for verifying the operation of parsing a keymap
file and compiling a keyboard description from it.
2009-04-10 12:33:31 -07:00
Dan Nicholson abbd141935 Add interface to compile keyboard description from keymap files
We need to support generating a keyboard description from a keymap file
because there are just some cases where RMLVO or ktcsg is not enough.

The map choosing logic has been refactored into its own function and now
supports choosing a named or default keymap.
2009-04-10 12:25:51 -07:00
Dan Nicholson e98eb80509 test: Remove extraneous includes
These programs don't actually use the internal API.
2009-04-09 20:52:26 -07:00
Dan Nicholson 0280b10df9 Make XkbcInitAtoms externally accessible
Applications (like the server) need to initialize the atoms system
before using the rest of the library. Maybe it should just init itself
implicitly.
2009-04-09 14:29:32 -07:00
Dan Nicholson f5d37e279a Constify public API
There's no reason the arguments can't be const.
2009-04-08 17:59:15 -07:00