summaryrefslogtreecommitdiff
path: root/src/text.c
AgeCommit message (Collapse)AuthorFilesLines
2014-04-22keymap: don't use darray in xkb_mod_setRan Benita1-2/+2
Instead just statically allocate the mods array (of size MAX_MOD_SIZE = 32). The limit is not going anywhere, and static allocations are nicer (nicer code, no OOM, etc.). It's also small and dense enough. Signed-off-by: Ran Benita <ran234@gmail.com>
2014-04-22keymap: add and use xkb_mods_{foreach,enumerate}()Ran Benita1-1/+1
To iterate over an xkb_mod_set. Slightly nicer interface and makes transitioning from darray easier. Signed-off-by: Ran Benita <ran234@gmail.com>
2014-04-19text: take xkb_mod_set instead of the entire keymapRan Benita1-8/+9
The modifier printing functions only need the modifier information, they don't care about keys or leds, etc. Signed-off-by: Ran Benita <ran234@gmail.com>
2014-04-19Add struct xkb_mod_setRan Benita1-3/+4
The only thing that the compilation phase needs the keymap for currently is for access to the modifier information (it also modifies it in place!). We want to only pass along the neccessary information, to make it more tractable and testable, so instead of passing the entire keymap we add a new 'mod_set' object and pass a (const) reference to that. The new object is just the old array of 'struct xkb_mod'. Signed-off-by: Ran Benita <ran234@gmail.com>
2014-04-19keymap: move ModNameToIndex from text.c and use it in keymap.cRan Benita1-14/+0
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-02-08Use (1u << idx) instead of (1 << idx) where appropriateRan Benita1-7/+7
It doesn't matter (I think), since the implicit conversion doesn't have any effect (e.g. sign-extension). But it's better to be aware of the type. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-08-02scanner: allow empty key name literalsRan Benita1-2/+2
Some keymaps actually have this, like the quartz.xkb which is tested. We need to support these. https://bugs.freedesktop.org/show_bug.cgi?id=67654 Reported-By: Gatis Paeglis <gatis.paeglis@digia.com> Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-31keymap: remove struct xkb_key_redirect_actionRan Benita1-2/+2
The file src/xkbcomp/action.c already doesn't handle this action type and fails if it encounters it. So lets not pretend to do something with it, and ignore it rather than failing. If we/someone wants this we can consider implementing it. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18text: some style changesRan Benita1-57/+53
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18text: clean up and fix the *MaskText functionsRan Benita1-73/+53
The snprintf trick that LedStateText and ControlMaskText do cannot work, because you can't use the buffer as an argument to write to itself! (posix at least has 'restrict' there). So those two actually never worked for more than one value (i.e. with a +). Fix that, and do the same cleanup to ModMaskText. Now we have 3 functions which look exactly the same, oh well. Also increase the context text buffer size, you never know. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Change 'indicator' to 'led' everywhere possibleRan Benita1-1/+1
The code currently uses the two names interchangeably. Settle on 'led', because it is shorter, more recognizable, and what we use in our API (though of course the parser still uses 'indicator'). In camel case we make it 'Led'. We change 'xkb_indicator_map' to just 'xkb_led' and the variables of this type are 'led'. This mimics 'xkb_key' and 'key'. IndicatorNameInfo and LEDInfo are changed to 'LedNameInfo' and 'LedInfo', and the variables are 'ledi' (like 'keyi' etc.). This is instead of 'ii' and 'im'. This might make a few places a bit confusing, but less than before I think. It's also shorter. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-30action: don't allow private actions with a known typeRan Benita1-1/+1
Some obscure bug having to do with Private actions; see the comments. This was prompted by: https://bugs.freedesktop.org/show_bug.cgi?id=56491 Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-22Split the mods, layout, leds parts of xkb_state_componentsRan Benita1-11/+11
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-18Move _text() functions from keymap-dump to text.cRan Benita1-0/+71
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-18Remove a couple more uses of static char buffersRan Benita1-4/+2
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-18Contextualize GetBuffer()Ran Benita1-28/+7
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-18Clean up xkb_sym_interpret a bitRan Benita1-12/+1
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-06Replace 0xff with MOD_REAL_MASK_ALLRan Benita1-1/+1
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-06Remove now-unneeded mod type annotationsRan Benita1-13/+6
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-06text: explicitly take mod_type in mod functionsRan Benita1-58/+15
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 Benita1-64/+51
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 Benita1-54/+40
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 Benita1-24/+14
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-06Remove the XKB_NUM_VIRTUAL_MODIFIERS limitRan Benita1-31/+7
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-09-27Don't limit key names to 4 charactersRan Benita1-12/+5
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-24Rename map.{c,h} to keymap.{c,h}Ran Benita1-1/+1
Seeing as we don't like "map" anymore. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-16Organize src/ and test/ headersRan Benita1-0/+1
- Add context.h and move context-related functions from xkb-priv.h to it. - Move xkb_context definition back to context.c. - Add keysym.h and move keysym upper/lower/keypad from xkb-priv.h to it. - Rename xkb-priv.h to map.h since it only contains keymap-related definitions and declarations now. - Remove unnecessary includes and some and some other small cleanups. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-11kbproto unentanglement: XkbSI match flagsDaniel Stone1-8/+8
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-11kbproto unentanglement: control actionsDaniel Stone1-14/+14
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-10kbproto unentanglement: XkbIM_*Daniel Stone1-11/+11
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-10kbproto unentanglement: action typesDaniel Stone1-41/+41
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-10Remove deprecated actionsDaniel Stone1-16/+17
We didn't do anything with ISO_Lock, ActionMessage, RedirectKey, and the device-specifying variants of the pointer actions, so remove those. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-10kbproto unentanglement: XkbNumVirtualModsDaniel Stone1-8/+8
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-10kbproto untanglement: XkbKeyNameLengthDaniel Stone1-1/+1
Define it ourselves as XKB_KEY_NAME_LENGTH and use that, instead of the one from XKB.h. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-03Unify some string tables from xkbcomp, text and keymap-dumpRan Benita1-51/+194
We move the LookupEntry struct from expr.h to text.h, along with most of the lookup tables. This makes them available everywhere. Looking up a value in the LookupEntry format is slower than direct index mapping, but it allows multiple names per value (with the canonical one being first) and "all"- and "none"-type masks. These functions are not used anywhere efficiency matters. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03Convert rest of names in xkb_keymap back to atomsRan Benita1-1/+1
These were kept as atoms, but since the keymap was exposed in the API, we converted them to strings; no the keymap is no longer exposed, so we can go back to atoms. They make the keymap smaller (at least on 64-bit machines) and the comparisons faster. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-03Use XKB_MOD_INVALID instead of XkbNoModifierRan Benita1-1/+1
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02Move enum xkb_file_type to xkbcomp/ast.hRan Benita1-17/+0
This is a more suitable place for this enum, since it's internal to xkbcomp. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02xkbcomp: clean up compile_keymap functionRan Benita1-15/+11
We make the xkb_file_type enum sequential instead of masks, and then we don't have to repeat the file types several times in the function. Makes the code cleaner. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-10Modernize struct xkb_modsRan Benita1-14/+21
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-07Remove xproto build dependencyRan Benita1-8/+15
Very little left to do for this. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07Handle key names consistentlyRan Benita1-1/+1
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-07filecomp: fix path and error messageRan Benita1-6/+6
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07Use only one set of core mod name-to-index functionsRan Benita1-11/+34
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-07keymap-dump: use ActionTypeTextRan Benita1-21/+21
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27Drop Xkbc prefix of text functionsRan Benita1-25/+25
Not really needed and inconsistent. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27Use xkb_mod_mask_t and xkb_mask_index_t throughoutRan Benita1-11/+15
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18Get rid of xkb_key_namesRan Benita1-3/+3
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-17Run source tree through uncrustifyDaniel Stone1-29/+29
.uncrustify.cfg committed for future reference also, but had to manually fix up a few things: it really likes justifying struct initialisers. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-12Enlarge keysym name buffers and mention in commentRan Benita1-1/+1
The longest keysym is 27 chars long. Signed-off-by: Ran Benita <ran234@gmail.com>