Commit Graph

749 Commits (233d85c427cbb9ecc53e9bc9784ceb0bd10fb87b)

Author SHA1 Message Date
Ran Benita 233d85c427 types: move preserve directly into xkb_kt_map_entry
Currently each xkb_key_type has a preserve array, which is only allocated
if a preserve[] statement is specified in the type. In this case each map
entry has an element in the array.

The space savings are negligible; put this field where it logically
belongs.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 13:20:37 +03:00
Ran Benita 6b75dd2dcb Fix virtual modifiers mask extraction
The calculations were performed incorrectly in several places,
specifically shifting by 16 instead of 8 (= XkbNumModifiers) and masking
with 0xff instead of 0xffff.

More stuff that probably never worked as intended. This also makes these
more grep-able when we remove the vmods/real_mods separation.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 13:20:37 +03:00
Ran Benita 796dccabe8 types: small changes
Just make things easier to follow, no functional changes.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 13:20:37 +03:00
Ran Benita 4c00278c82 Remove xproto build dependency
Very little left to do for this.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 13:20:37 +03:00
Ran Benita b0b11c4e2e types: don't use canonical/required types
Xkb required every keymap to have at least the four following canonical
types: ONE_LEVEL, TWO_LEVEL, ALPHABETIC, KEYPAD. This is specified in
e.g. the kbproto spec and XkbKeyTypesForCoreSymbols(3) man page.

If these types are not specified in the keymap, the code specifically
checks for them and adds them to the 4 first places in the types array,
such that they exist in every keymap. These are also the types (along
with some non-required 4-level ones) that are automatically assigned to
keys which do not explicitly declare a type (see FindAutomaticType in
symbols.c, this commit doesn't touch these heuristics, whcih are also not
very nice but necessary).

The xkeyboard-config does not rely on the builtin xkbcomp definitions of
these types and does specify them explicitly, in types/basic and
types/numpad, which are virtually always included.

This commit removes the special behavior:
- The code is ugly and makes keytypes.c harder to read.
- The code practically never gets run - everyone who uses
  xkeyboard-config or a keymap based upon it (i.e. everyone) doesn't need
  it. So it doesn't get tested.
- It mixes policy with implementation for not very good reasons, it
  seems mostly for default compatibility with X11 core.
- And of course we don't need to remain compatible with Xkb ABI neither.

Instead, if we read a keymap with no types specified at all, we simply
assign all keys a default one-level type (like ONE_LEVEL), and issue
plenty of warnings to make it clear (with verbosity >= 3). Note that
this default can actually be changed from within the keymap, by writing
something like
    type.modifier = Shift
    type.whatever_field = value
in the top level of the xkb_types section. (This functionality is
completely unused as well today, BTW, but makes some sense).

This change means that if someone writes a keymap from scratch and
doesn't add say ALPHABETIC, then something like <AE11> = { [ q Q ]; }; will
ignore the second level. But as stated above this should never happen.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 13:20:37 +03:00
Ran Benita be82f08221 types: add a general overview
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 13:20:37 +03:00
Ran Benita c1ea23da5c symbols: remove support for key behaviors
The possible key behaviors are:
KB_RadioGroup, KB_Overlay1, KB_Overlay2: already removed support for
these.
KB_Lock (with or without KB_Permanent): used to ignore key presses or
releases to simulate and deal with some legacy keyboard behaviors
(like keys that physically lock). Not used at all.

We already ignore them while processing key events in state.c, so make
it official.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 7c89f34e63 keycodes: small changes
to make it a bit nicer.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita b2c4331ac3 Handle key names consistently
We treat the key names as fixed length, non NUL terminated strings of
length XkbKeyNameLength, and use the appropriate *Text functions to
print them. We also use strncpy everywhere instead of memcpy to copy
the names, because it does some NUL padding and we might as well.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita c548c81529 keycodes: add a general overview
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 15541766b0 expr: make ResolveLevel return zero-based level
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 59d947c9c1 Add and use xkb_level_index_t
Several types are used over the code for shift levels; better to use
just one.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita b804aec292 action: drop global actionInitialized
The action.c needs to use two constant Expr values, constTrue and
constFalse. To do this is keeps to static globals Expr's of type boolean
and the values "true" and "false" which need to be interned (and thus
context specific). The interning means they can't be made static const,
so there's a global flag and initializer function.

Instead of using this unsafe global state, we can simply use an integer
boolean expression (1 and 0) instead of a string one ("true" and
"false") and make them const.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 6f08a2cfa0 expr: constify function arguments
We need this for later.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita f2ecd6650a log: allow to resore default log function
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 18048cb7bf darray: fix formatting
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 9617b092e2 filecomp: fix path and error message
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 1d570a6d46 interactive: add support to run from keymap file
This is useful for quickly testing a random keymap file. Use -k <PATH>.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita cfd978b89d keyseq: use our own keysyms
Instead of <X11/keysym.h>

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita cead852713 Replace more defines with enums
Mostly the ones used to track the fields of types/keys/leds which were
already defined.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 3bea189bd5 Make top level Handle*File functions nicer
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 82ee45b374 Use xkb_led_index_t throughout
And use XKB_LED_INVALID instead of _LED_Unbound, which served the same
purpose here.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 09dac54b97 vmod: remove unused fields
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 6eb5929d48 README: s/xkb_desc/xkb_keymap
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 7c7e434151 Use only one set of core mod name-to-index functions
These were repeated 5 times.

Note that this changes the ABI slightly: XKB_MOD_NAME_CAPS is changed
from "Caps Lock" to "Lock", which is the ordinary legacy mod name for
it. Since its hidden behind a #define, it's best to stay compatible with
the old names (as I think was intended, given that "Mod1", etc. are the
same).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita c6dee4640a map: fix incorrect return value
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:39 +03:00
Ran Benita ae968f855a map: fix virtual mod index calculation
The current code made us miss vmod index 0. Also look at the code in
vmod.c:LookupVModMask.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 10:50:15 +03:00
Ran Benita 80ab9f12b4 keymap-dump: use ActionTypeText
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 10:47:43 +03:00
Ran Benita d53fcf53f8 keymap-dump: use SITextMatch
text.c has the exact same function.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 10:47:43 +03:00
Ran Benita 20bef734d8 keymap-dump: clean up write_buf function
It would have been nice to use open_memstream here if it was portable
enough (maybe someday it will?).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 10:47:41 +03:00
Ran Benita 4c21275301 Add an interactive evdev test
The program reads key events from evdev input devices, puts them through
the library and prints some information about them. It's nice for
experimenting, quick testing and trying to break it with random stuff
(already found some!).

It is called "interactive" for lack of a better name. It's a bit
hackish, but can easily be extended, made more portable etc, in the
future.

Signed-off-by: Ran Benita <ran234@gmail.com>

Conflicts:
	Makefile.am
	test/.gitignore
2012-07-28 11:43:15 +02:00
Ran Benita 41d9afc556 Remove ExprResult
Convert the IdentLookup typedef away from ExprResult, which drags along
everything else. This should also make all of the conversions explicit.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 15:31:03 +03:00
Ran Benita 6917901f81 expr: remove support for evaluating string as integer
As the comment nicely puts it, this is a bit weird. When you try to
evaluate an expression of type string into an integer, what it does is:
    "" -> 0
    "c" -> (ascii value, i.e. like a char literal)
    more than one char -> error
The first one is obviously not very useful; why not just write 0?
The second one might be useful (though I don't see where in a keymap
it would be), but I don't think anyone would consider trying "X" for
that anyway.

A look through xkeyboard-config shows "" only used once as a string, and
"X" also only used as strings (and mostly in geometry which we don't
evaluate anyway). And I seriously doubt it's used (purposely) anywhere
else. So remove it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 14:15:39 +03:00
Daniel Stone dd0f3c6dc2 Don't create contexts with no include paths
Clean up the return code handling from
xkb_context_add_include_paths_default, and thus fail context creation if
we can't add any of the default include paths, but were asked to.  If
this happens, dump the DFLT_XKB_CONFIG_ROOT out in the log message, so
at least we know what we aren't looking at.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-27 11:59:55 +02:00
Daniel Stone ca7927ae60 context test: Use test_get_context()
So we don't die if we haven't got a valid global include path.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-27 11:59:55 +02:00
Ran Benita bd927abf3d expr: drop ExprResult from ResolveEnum
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:14 +03:00
Ran Benita 38614c886c expr: drop ExprResult from ResolveMask
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:14 +03:00
Ran Benita 2e4933cda7 expr: drop ExprResult from ResolveInteger
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita d568228988 expr: drop ExprResult from ResolveButton
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 6ec135700d expr: drop ExprResult from ResolveLevel
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 000528dd59 expr: drop ExprResult from ResolveKeyCode
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita e258f9ee07 expr: drop ExprResult from ResolveGroup
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 7026229210 expr: drop ExprResult from ResolveKeysym
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 0d262fa105 expr: drop ExprResult from ResolveBoolean
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 27f9492969 expr: drop ExprResult from ResolveString
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 025ca57905 expr: drop ExprResult from ResolveLhs
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 761b675cc3 expr: drop ExprResult from ResolveKeyName
Explicit is better than implicit, and this union makes it hard to follow
what's what, particularly the confusion with ival/uval.
The other Resolve functions will follow.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:56:11 +03:00
Ran Benita 01c81fa61e parser: untabify
Run vim's :%retab and some resulting indention fixes.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:49:09 +03:00
Ran Benita 724f62c8e3 Convert defines to enums in xkbcomp.h
For statement / expression types.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:49:06 +03:00
Ran Benita 35fb8b94cb Fix incorrect comparison
ExprFieldRef goes into the ExprDef op field, not the type field.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:47:32 +03:00