summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2012-10-10keycodes: refactor AddIndicatorNameRan Benita1-40/+34
Make it shorter and fix the XXX. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10keymap, state: don't assume led index < xkb_keymap_num_ledsRan Benita2-10/+8
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-09keysym: fix xkb_keysym_is_upper/lower() to work properlyRan Benita1-111/+494
Our current code (taken from the xserver) doesn't handle unicode keysyms at all, and there seem to be some other changes compared to libX11, which is what xkbcomp uses. So we just copy the code that does that from libX11. It would be much better to not have to hardcode unicode tables like that, but it's probably better than dealing with glibc locale stuff for now. It also doesn't affect our binary size much. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-09compat: fix bad interpret predicate mods "all" calculationRan Benita1-1/+1
Commit 9984d1d03cd78eb636c75cc2bbd2d240dc1dd72f changed the type of interpret->mods to xkb_mod_mask_t, but this bit of code assumes that the type is uint8_t. This code is not usually run (for example by our tests), but when it does keymap-dump would print out all of the modifiers (including the virtual ones) which causes recompilation of the output to fail miserably. https://bugs.freedesktop.org/show_bug.cgi?id=55769 Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06keymap: use xkb_mod_mask_t for interpret->mods and modmapRan Benita1-2/+2
These are both real modifier masks, but we keep this information only in the program logic now so when we change it we don't have to worry about the type. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06symbols: refactor AddModMapEntryRan Benita1-48/+33
It really asks for it. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06Replace 0xff with MOD_REAL_MASK_ALLRan Benita5-4/+6
To make it easier to see where it's used. The name is just to match MOD_REAL. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06expr: unify the real and virtual modifier functionsRan Benita6-48/+30
This again pushes the mod type annotation to the original call site, to make it easier to grep to see where the real/virtual distinction matters. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06Remove now-unneeded mod type annotationsRan Benita7-50/+40
Most of the mod type annotations can now be changed to MOD_BOTH, because if you pass a mask which can only contain real mods in the first place to e.g. ModMaskText, then MOD_REAL and MOD_BOTH will give the same result. In the cases where MOD_BOTH is only ever the argument, we just remove it. What's left is where it really "matters". Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06expr: share code for modifier functionsRan Benita1-68/+38
We can make more use of the functions in text.c now and remove some cruft. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06text: explicitly take mod_type in mod functionsRan Benita7-107/+58
This essentially "tags" each invocation of the functions with the modifier type of the argument, which allows for easy grepping for them (with the aim being, to remove anything but MOD_BOTH). Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06text: share code for modifiersRan Benita2-68/+55
Add static common functions which take enum mod_type, and change the existing ones to use them. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06Keep real and virtual mods in the same table in the keymapRan Benita11-156/+166
We change the keymap->vmods array into keymap->mods, and change it's member type from struct xkb_vmod to struct xkb_mod. This table now includes the real modifiers in the first 8 places. To distinguish between them, we add an enum mod_type to struct xkb_mod. Besides being a more reasonable approach, this enables us to share some code later, remove XKB_NUM_CORE_MODS (though the 0xff mask still appears in a few places), and prepares us to flat out remove the distinction in the future. This commit just does the conversion. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06Don't use shifted virtual modifier masksRan Benita5-40/+27
Modifier masks can be confusing in some places. For example, key->vmodmap only contains virtual modifiers, where the first is in position 0, the second in 1 etc., while normally in a xkb_mod_mask_t the virtual modifiers start from the 8th (XKB_NUM_CORE_MODS) position. This happens in some other places as well. Change all of the masks to be in the usual real+virtual format, and when we need to access e.g. keymap->vmods we just adjust by XKB_NUM_CORE_MODS. (This also goes for indexes, e.g. interpret->virtual_modifier). This makes this stuff easier to reason about. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06expr: don't expose LookupModIndexRan Benita3-6/+3
The Lookup* functions should remain a private implementation detail of the expr.c file. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06Remove VModInfo for nowRan Benita7-116/+81
VModInfo currently is only used to track which virtual modifiers were declared in the file which owns the VModInfo. This, in turn, is only used in ResolveVirtualModifier, which in turn is only used to resolve the virtualModifier field in an interpret statement (compat.c). In other words, it is used to ensure that interprets can only use a vmod which was declared in the same map. We remove this now, because it doesn't do much and distracts from other changes; we will later re-add it properly. Specificly, we will make it so that virtual modifiers are not the exception in that they modify the keymap directly, instead of keeping the changes in some *Info struct and commiting them to the keymap at the end of the compilation. (This is bad because if a vmod is added to the keymap, and then the compilation of this specific file fails, the change sticks around nonetheless). Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06vmod: don't allow to add a vmod with the name of a real modRan Benita1-0/+10
Otherwise strange thing might ensue. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06state: don't needlessly fetch the xkb_keyRan Benita1-4/+0
It's a leftover. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06vmod: remove merge argument from HandleVModDefRan Benita5-10/+5
It's unused and unneeded. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06Omit struct '_Name' from non-recursive struct typedefsRan Benita6-24/+24
Just a pet peeve. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06expr: don't allow "none" in LookupModIndexRan Benita1-6/+0
LookupModMask handles this before calling LookupModIndex, and the only other user in symbols.c doesn't handle this return value at all. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06keysym-utf: make keysym->unicode table a bit smallerRan Benita1-1/+2
Saves a few kbytes, and unlikely to change. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06Remove the XKB_NUM_VIRTUAL_MODIFIERS limitRan Benita6-108/+62
Turn the virtual modifiers arrays in the keymap to a single darray, which doesn't use this limit. The number of virtual modifiers is still limited by the size of xkb_mod_mask_t, so we make sure not to go over that. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06state: simplify xkb_state_mod_index_is_activeRan Benita1-13/+1
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06state: don't ignore type argument in xkb_state_mod_*_are_activeRan Benita1-5/+6
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06state: fix bad EFFECTIVE check in *_is_active()Ran Benita1-2/+2
This is a regression introduced in ed78fbcb30888cbfc6cd00. XKB_STATE_EFFECTIVE is just a OR of the other states, so using & here is completely wrong. So test/state shows for example: dumping state for LCtrl down: group English (US) (0): effective depressed latched locked mod Control (2): depressed latched locked dumping state for LCtrl + RAlt down: group English (US) (0): effective depressed latched locked mod Control (2): depressed latched locked mod Mod1 (3): depressed latched locked dumping state for RAlt down: group English (US) (0): effective depressed latched locked mod Mod1 (3): depressed latched locked dumping state for Caps Lock: group English (US) (0): effective depressed latched locked mod Lock (1): depressed latched locked led Caps Lock (0): active dumping state for Alt-Shift-+ group English (US) (0): effective depressed latched locked mod Shift (0): depressed latched locked mod Mod1 (3): depressed latched locked which is bogus. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06Use our types instead of int/uint32_t in a few placesRan Benita9-22/+23
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30Don't scan and parse useless mapsRan Benita6-102/+97
One physical xkb file may (and usually does) contain multiple maps. For example, the us symbols file contains a map for every variant. Currently, when we need a map from a file (specific or default), we parse the entire file into a list of XkbFile's, find the map we want and discard the others. This happens for every include statement. This is a lot of unnecessary work; this commit is a first step at making it better. What we do now is make yyparse return one map at a time; if we find what we want, we can stop looking and avoid processing the rest of the file. This moves some logic from include.c to parser.y (i.e. finding the correct map, named or default). It also necessarily removes the CheckDefaultMap check, which warned about a file which contains multiple default maps. We can live without it. Some stats with test/rulecomp (under valgrind and the benchmark): Before: ==2280== total heap usage: 288,665 allocs, 288,665 frees, 13,121,349 bytes allocated compiled 1000 keymaps in 10.849487353s After: ==1070== total heap usage: 100,197 allocs, 100,197 frees, 9,329,900 bytes allocated compiled 1000 keymaps in 5.258960549s Pretty good. Note: we still do some unnecessary work, by parsing and discarding the maps before the one we want. However dealing with this is more complicated (maybe using bison's push-parser and sniffing the token stream). Probably not worth it. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30scanner: don't strdup the file nameRan Benita1-10/+6
We don't modify it and there's no way to modify the original in the scanner_extra life time. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30scanner: share code in XkbParse{File,String}Ran Benita4-62/+70
Some refactoring to prepare for changes in the parse() function. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30scanner: remove uselss 'last symbol' error messageRan Benita1-3/+0
It never shows something useful. Besides, you already get the line number, which is enough. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30parser: remove XkbCompMapList ruleRan Benita1-8/+2
This rule allows you to put several xkb_keymaps in one file. This doesn't make any sense: only the default/first can ever be used, yet the others are fully parsed as well. Different keymaps should just be put in different files. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30parser: remove XkbConfig ruleRan Benita1-17/+1
This rule allows you to write file maps as: xkb_keycodes <BLA> = 5; [...] instead of the usual format which is: xkb_keycodes { <BLA> = 5; [...] }; This is not documented, It is also not used in xkeyboard-config, and I have never run into it otherwise. It also only allows one map per file. It *might* be used in some obscure place, but probably nothing we should care about; the simplified grammar is more useful for us now. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30Don't use %z printf formatRan Benita1-2/+2
Some libc's don't support it. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-30rules: always initialize idx variableRan Benita1-0/+1
gcc didn't catch this one. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27keymap-dump: make it look better with long key namesRan Benita1-3/+3
Not worth messing around with too much, just make it legible. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27Fix type of keycode in parser and astRan Benita5-5/+13
For some reason keycodes were listed under mapFlags in the yylval union. Fix it and some sanity checks. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27Don't limit key names to 4 charactersRan Benita12-206/+158
Currently you can't give a key in xkb_keycodes a name of more than XKB_KEY_NAME_LENGTH (= 4) chars. This is a pretty annoying and arbitrary limitation; it leads to names such as <RTSH>, <COMP>, <PRSC>, <KPAD> etc. which may be hard to decipher, and makes it impossible to give more standard names (e.g. from linux/input.h) to keycodes. The purpose of this, as far as I can tell, was to save memory and to allow encoding a key name directly to a 32 bit value (unsigned long it was). We remove this limitation by just storing the names as atoms; this lifts the limit, allows for easy comparison like the unsigned long thing, and doesn't use more memory than previous solution. It also relieves us from doing all of the annoying conversions to/from long. This has a large diffstat only because KeyNameText, which is used a lot, now needs to take the context in order to resolve the atom. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27xkbcomp/keymap: use default interpret in ApplyInterpsToKeyRan Benita1-14/+19
This makes the code easier to follow and does more explicitly what the xkblib spec says: If no matching symbol interpretation is found, the server uses a default interpretation where: sym = 0 flags = XkbSI_AutoRepeat match = XkbSI_AnyOfOrNone mods = 0 virtual_mod = XkbNoModifier act = SA_NoAction If a level doesn't have any keysyms, we don't apply anything to it. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27state: add missing const in get_one_symRan Benita1-1/+1
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27Add xkb_state_key_get_one_symDaniel Stone1-0/+16
The trivial wrapper around xkb_state_key_get_syms that every user to date has implemented. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-26Fix size_t vs. %d warningDaniel Stone1-2/+2
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-25symbols: get rid of autoTypeRan Benita1-46/+41
The autoType variable is supposed to tell us whether the type was explicitly specified by the user or was detected automatically according to the keysyms. It then allows us to know whether to prints the type when we dump the keymap to a string or not. Right now it is not always set when we find an automatic type, according to some apparently legacy rules. We change it to simply this: type computed automatically? -> don't print. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-25symbols: separate type-finding logic from CopySymbolsDefRan Benita1-58/+62
It's easier to follow this in isolation. Besides, previously the error reporting wasn't done very well. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24keymap: remove some more unneeded macrosRan Benita5-32/+11
It clearer to just access the needed data directly. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24keymap: store a pointer to the type in xkb_group instead of indexRan Benita6-40/+33
Gets rid of some more unneeded indirection, including the XkbKeyType macro. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24keymap, symbols: improve xkb_key memory layoutRan Benita6-163/+103
Add struct xkb_group and xkb_level for use in xkb_key, to mirror how it's done in KeyInfo, GroupInfo, LevelInfo in symbols.c. This corresponds more nicely to the logical data layout (i.e. a key has groups which have levels), and also removes a lot of copying and ugly code due to the index indirections and separate arrays which were used before. This uses more memory in some places (e.g. we alloc an action for every level even if the key doesn't have any) but less in other places (e.g. we no longer have to pad each group to ->width levels). The numbers say we use less overall. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24symbols: move keysyms into LevelInfoRan Benita2-175/+140
Instead of maintaining a syms array in the GroupInfo + sym_index's in the levels. This simplifies the code somewhat. In order not to alloc for every level instead of every group, we only do it if the level has more than one keysym (with a union). Since for now this is a special case, it actually works out better memory-wise. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24symbols: fix index-out-of-bounds in FindAutomaticTypeRan Benita1-1/+2
If we enter this branch, we have 3 <= width <= 4, so if the width is 3 than syms[3] is out of bounds. Happily inherited from xkbcomp. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-24symbols: remove unneeded optimizationRan Benita1-4/+0
The levels will be resized to the number of levels of the type anyway, so removing useless levels from the end here is unneeded. Signed-off-by: Ran Benita <ran234@gmail.com>