summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2012-08-10Modernize struct xkb_modsRan Benita10-239/+159
Currently xkb_mods has the following members: - uint8_t real_mods - 8 X11 core mods - xkb_mod_mask_t vmods - 16 virtual mods, zero-based index - xkb_mod_mask_t mask - the computed effective *real* modifier mask, basically a cache for the first two which is: real_mods | real mods computed from vmods Our API acts on masks which combine the real_mods and vmods into a single value, which is: 8 first bits real mods | 16 next bits virtual mods (XkbNumModifiers = 8, XkbNumVirtualMods = 16). This is also the format which ResolveVModMask uses (which is where all the modifier masks really "come from", e.g. "Shift+Lock+Level5" -> xkb_mod_mask_t). What the code does now after getting the mask from ResolveVModMask, is to break it into real part and virtual part and store them seperately, and then join them back together when the effective mask is calculated. This is all pretty useless work. We change xkb_mods to the following: - xkb_mod_mask_t mods - usually what ResolveVModMask returns - xkb_mod_mask_t mask - the computed mask cache And try to consistently use the word "mods" for the original, non-effective mods and mask for the effective mods (which can only contain real mods for now, because things break otherwise). The separation is also made clearer. The effective masks are computed by UpdateModifiersFromCompat after all the sections have been compiled; before this the mask field is never touched; after this (i.e. map.c and state.c) the original mods field is never touched. This single execption to this rule is keymap-dump.c: it needs to print out only the original modifiers, not computed ones. This is also the reason why we actually keep two fields instead keeping one and modifying it in place. The next logical step is probably to turn the real mods into vmods themselves, and get rid of the distinction entirely (in a compatible way). Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-09Fix xkb_keymap::vmods typeRan Benita1-1/+1
It maps a vmod to a mask, of course. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-09types: don't compute effective masks here as wellRan Benita2-27/+8
After compiling all of the sections, UpdateModifiersFromCompat does all of the vmod -> real mods translations, including types/kt_entries. keytypes.c also has code that does that, but it's unneeded: - Later sections don't look at their effective masks, so doing it later is fine. - When this code is executed, the vmods -> real mods mapping is empty (that is set up later), so VModsToReal has no effect here. So we can just remove it. However UpdateModifiersFromCompat didn't update the preserve mask, so do that. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-09types: get rid of PreserveInfoRan Benita1-181/+120
We don't need the indirection. We store the preserve mask directly in the entry, and create a new one if it doesn't exists (which is exactly what the current code does in a roundabout way). Incidentally this fixes a bug where the effective modifier mask of the entries' preserve[] wasn't calculated, so the virtual modifiers had no effect there. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-09keymap-dump: use VModMaskTextRan Benita1-66/+14
The difference between the two are irrelevant here. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-09Fix warningRan Benita1-1/+1
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-08Add xkb_map_mod_mask_remove_consumedDaniel Stone1-13/+49
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>
2012-08-08Add xkb_log_level enum rather than using syslogDaniel Stone2-25/+26
Instead of relying on people including syslog.h, add our own XKB_LOG_LEVEL_* defines. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08Rules: mmap() rules file instead of using getc()Daniel Stone1-21/+43
Good for a small performance win on my system. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08Always have at least one level in typesDaniel Stone1-1/+1
The ONE_LEVEL definition from xkeyboard-config doesn't specify any actual levels, but there's an implicit (anything unmatched) -> Level1 rule. Given this, each type actually has at least one level, whether or not it specifies anything. Fixes stringcomp. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08IncludeStmt: Remove useless 'path' memberDaniel Stone3-4/+1
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08Remove unused vmodmask calculationDaniel Stone1-8/+0
This was basically an open-coded VModsToReal, which we were using in the line immediately below. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08Print failed include paths on failure to find rulesDaniel Stone1-5/+9
Thus giving a hint as to which directory we're trying to find. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08Move xkb_context struct to xkb-priv.hDaniel Stone2-18/+18
So we can print more intelligent debugging messages without needing helper functions for the failed_includes array. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08context: Maintain list of failed include pathsDaniel Stone1-10/+18
Keep around a list of paths we tried to add but couldn't. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08More useful error message on failing RMLVO -> KcCGSTDaniel Stone1-2/+5
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08Move more of xkb_map_new_from_rmlvo into compilationDaniel Stone1-23/+22
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08Staticise xkb_map_new_from_kccgstDaniel Stone2-61/+11
We didn't expose this to the outside world, and its only trivial user was xkb_map_new_from_rules. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08Add support for default rules/model/layoutDaniel Stone1-7/+10
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>
2012-08-08Warning fixesDaniel Stone2-1/+2
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08Add API to query whether a modifier is consumedRan Benita1-0/+44
Currently the user has no way of knowing which of the active modifiers have been used in the translation of a keycode to its keysyms. The use case is described in the GTK docs: say there's a menu accelerator activated by "<Alt>+". Some layouts have "+" shifted, and some have it on the first level. So in keymaps where "+" is shifted, the Shift modifier is consumed and must be ignored when the user is testing for "<Alt>+". Otherwise, we may get "<Alt><Shift>+" and the accelerator should not actually fire. For this we also use the preserve[] information in the key types, which can forces us to report modifiers as unconsumed even if they were used in the translation. Until now we didn't do anything with this information. The API tries to match its surronding. It's not very efficient but this can be fixed. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-08types: remove default typeRan Benita1-111/+35
The default type is copied over for each new key type to build on. Further, it can be modified from within the xkb_types section itself, with statements such as "type.modifiers = Lock" which affect all subsequent type definitions. The default type is (well, by default) just the simplest one level type possible, with name "default". When no types are defined at all, it is copied over to the keymap as the single type. xkeyboard-config never changes the default type. There is also no sane use case for doing so; changing any thing there doesn't make sense. So instead of doing all the hard work of maintaining and copying this type, which is practically never used, just remove it and initialize new types appropriately. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07types: store atoms instead of strings for level and type namesRan Benita4-42/+23
We don't use these strings much, so storing them in the manner they were compiled saves some copying and space. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07types: use regular array for map entriesRan Benita6-19/+29
This array is only initialized once. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07types: use regular array for typesRan Benita6-31/+34
The current code doesn't resize it any more. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07types: remove DeleteLevel1MapEntriesRan Benita2-18/+7
If there is no map entry for some modifier combination, the default is to use level 1. The removed code is an optimization to save some space by removing these entries. But it doesn't actually save any space, and did not in fact remove all level 1 entries (it walks the array while modifying it so there's an off-by-one error). We can instead keep them in the types but just not print them in keymap-dump.c, to get about the same behavior. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07types: move preserve directly into xkb_kt_map_entryRan Benita4-33/+10
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-07Fix virtual modifiers mask extractionRan Benita4-13/+13
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-07types: small changesRan Benita1-111/+158
Just make things easier to follow, no functional changes. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07Remove xproto build dependencyRan Benita3-10/+16
Very little left to do for this. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07types: don't use canonical/required typesRan Benita4-279/+26
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-07types: add a general overviewRan Benita1-0/+96
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07symbols: remove support for key behaviorsRan Benita3-48/+10
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-07keycodes: small changesRan Benita1-67/+63
to make it a bit nicer. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07Handle key names consistentlyRan Benita10-88/+81
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-07keycodes: add a general overviewRan Benita1-0/+88
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07expr: make ResolveLevel return zero-based levelRan Benita2-6/+3
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07Add and use xkb_level_index_tRan Benita9-40/+46
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-07action: drop global actionInitializedRan Benita1-34/+13
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-07expr: constify function argumentsRan Benita3-58/+79
We need this for later. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07log: allow to resore default log functionRan Benita1-1/+1
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07darray: fix formattingRan Benita1-118/+101
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07filecomp: fix path and error messageRan Benita1-6/+6
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07Replace more defines with enumsRan Benita3-118/+127
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-07Make top level Handle*File functions nicerRan Benita7-116/+97
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07Use xkb_led_index_t throughoutRan Benita2-14/+12
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-07vmod: remove unused fieldsRan Benita2-10/+2
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07Use only one set of core mod name-to-index functionsRan Benita5-85/+64
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-07map: fix incorrect return valueRan Benita1-1/+1
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07map: fix virtual mod index calculationRan Benita1-4/+4
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>