summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2013-03-18keycodes: remove KeyNamesInfo::mergeRan Benita1-3/+1
Not used. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: unwrap KeyNameInfoRan Benita1-32/+24
We don't need the struct any more, it only contains one field now. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: remove file_idRan Benita1-27/+13
The file_id thing is used to identify the XkbFile some statement originally came from. This is needed to avoid spurious warnings; for example, if you write the same alias twice in a file, that's redundant, and you'd want a warning about it. However if intentionally override it from another file, that's fine, and you shouldn't get a warning. So by comparing the file_id's the needed log verbosity is changed. However, the file_id mechanism is really not needed, because we already have that info! Each KeyNamesInfo corresponds to one XkbFile, so if the conflict occurred while handling that one file -> same_file = true, and if it occurs while merging two Info's -> same_file = false. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap: don't use darray for key aliasesRan Benita4-58/+56
With a little tweak to the copy-to-keymap routine in keycodes.c we can use a normal array. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: don't do unnecessary copies while mergingRan Benita1-49/+52
If 'into' in empty we can just steal 'from'. Also move the alias-merging into the big function, it's nicer this way. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18state: small style fixRan Benita1-11/+13
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Move a couple of general keymap functions from keycodes.cRan Benita6-86/+47
To get a key by name and resolve an alias - this makes sense for everyone. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: remove unneeded alias conflict checkRan Benita1-67/+35
This is already checked when adding a new alias and merging aliases, so it can never happen when we get to copying to the keymap. Also the log verbosity decision there is quite useless, we should just warn always and be done with it. So we can remove the file_id from AliasInfo, and collapse the alias functions together. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18xkbcomp: handle XKB file include's betterRan Benita6-117/+75
The 'merge_mode' situation is quite messy, and we've introduced a regression compared to original xkbcomp: when handling a composite include statement, such as replace "foo(bar)+baz(bla)|doo:dee" and merging the entire resulting *Info back into the including *Info, we actually use the merge mode that is set by the last part (here it is "augment" because of the '|'), when we should be using the one set for the whole statement (here "replace"). We also take the opportunity to clean up a bit. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Build cleanly with clangRan Benita2-7/+1
clang doesn't like the use of typeof with out default flags, so just don't use it. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap: abstract a bit over the keymap formatRan Benita6-120/+241
Make it a bit easier to experiment with other formats. Add a struct xkb_keymap_format_operations, which currently contains the keymap compilation and _get_as_string functions. Each format can implement whatever it wants from these. The current public entry points become wrappers which do some error reporting, allocation etc., and calling to the specific format. The wrappers are all moved to src/keymap.c, so there are no XKB_EXPORT's under src/xkbcomp/ anymore. The only format available now is normal text_v1. This is all not very KISS, and adds some indirection, but it is helpful and somewhat cleaner. 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 Benita4-77/+57
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-18More spelling errorsRan Benita4-5/+5
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18parser: also skip 'section' ELEMENTRan Benita1-1/+1
It's for geometry only. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18ast-build: remove malloc_or_dieRan Benita1-82/+93
This should be fixed properly. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: fix spelling in error messageRan Benita1-1/+1
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Remove list.hRan Benita1-489/+0
We don't use it anymore and it's easy to add back if needed. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap-dump: move writing 'key {}' in symbols to its own functionRan Benita1-100/+107
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap-dump: remove some ugly empty linesRan Benita1-6/+6
xkbcomp prints them too, but that's just annoying. Also xkb_keycodes doesn't have it already. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap-dump: don't indent after xkb_keymap {Ran Benita1-50/+50
xkbcomp doesn't indent there, so it's easier to diff. Also saves some horizontal space which is sorely needed when looking at these files (especially the xkb_symbols). Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap-dump: style cleanupsRan Benita1-74/+45
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18ast: add error handling to XkbFileFromComponentsRan Benita1-24/+32
And try to not repeat ourselves. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Fix dead assignmentsRan Benita4-22/+17
"Value stored to 'stmt' is never read" "Value stored to 'grp_to_use' is never read" And change 'grp' to 'group' if we're here. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keysym: print unicode keysyms uppercase and 0-paddedRan Benita1-3/+5
Use the same format as XKeysymToString. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Change some log functions to take ctx instead of keymapRan Benita3-10/+10
They don't need the keymap, only the context. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: some minor styleRan Benita1-18/+25
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18action: s/hndlrType/handler_typeRan Benita1-5/+5
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18compat: make it clear which 'dflt' is meantRan Benita1-19/+21
Also s/dflt/default. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18symbols: make it clear which 'dflt' is meantRan Benita1-18/+18
A bit easier at a glance. Also, vowels are cool, so just say 'default'. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18ast: constify argumentRan Benita2-2/+2
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18symbols: fix bad 'merge' assignmentRan Benita1-1/+1
Bug introduced in 2a5b0c9dc1ad1488ecc6b139fd70e464eb687da6, was causing some keys to be merged incorrectly. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Change 'indicator' to 'led' everywhere possibleRan Benita13-227/+218
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>
2013-03-18state: fix unbound virtual modifier bugRan Benita1-1/+10
Recent xkeyboard-config introduced the following line in symbols/level3: vmods = LevelThree, However, the XKM format which xkbcomp produces for the X server can't handle explicit virtual modifiers such as this: https://bugs.freedesktop.org/show_bug.cgi?id=4927 So by doing the following, for example: setxkbmap -layout de (or another 3-level layouts) xkbcomp $DISPLAY out.xkb xkbcomp out.xkb $DISPLAY The modifier is lost and can't be used for switching to Level3 (see the included test). We, however, are affected worse by this bug when we load the out.xkb keymap. First, the FOUR_LEVEL_ALPHABETIC key type has these entries: map[None] = Level1; map[Shift] = Level2; map[Lock] = Level2; map[LevelThree] = Level3; [...] Now, because the LevelThree virtual modifier is not bound to anything, the effective mask of the "map[LevelThree]" entry is just 0. So when the modifier state is empty (initial state), this entry is chosen, and we get Level3, instead of failing to match any entry and getting the default Level1. The difference in behavior from the xserver stems from this commit: acdad6058d52dc8a3e724dc95448300850d474f2 Which removed the entry->active field. Without bugs, this would be correct; however, it seems in this case we should just follow the server's behavior. The server sets the entry->active field like so in XKBMisc.c: /* entry is active if vmods are bound */ entry->active = (mask != 0); The xkblib spec explains this field, but does not specify how to initialize it. This commit does the same as above but more directly. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-12-06Parser: Initialise geometry elements for VarDeclDaniel Stone1-3/+3
We were using uninitialised memory whilst parsing geometry, leaving random contents as the return for shape/overlay/etc sections. Somehow this actually worked everywhere but under Java. https://bugs.freedesktop.org/show_bug.cgi?id=57913 Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-11-11state: rename state->cur to state->componentsRan Benita1-68/+70
'cur' doesn't make sense anymore. 'components' is a bit long for this, but not too bad, and nothing better comes to mind. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-11-11state: don't keep the previous state components in xkb_stateRan Benita1-7/+9
There is really no need to keep this in the struct, we can just allocate it on the stack when we need to. Don't know why I did it this way. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-11-11keymap: wrap the layout parameter if it is out of range for the keyRan Benita3-2/+19
The functions num_levels_for_key() and get_syms_by_level() have a 'layout' parameter. Currently it is expected that this value is always legal for the key, as determined by num_layouts_for_key(). However, there are legitimate use cases for passing an out-of-range layout there, most probably passing the effective layout, and expecting to get the keysyms/levels for just this layout. So we wrap it just as we do in the xkb_state_* functions. This is also useful for stuff like this: http://developer.gnome.org/gdk/stable/gdk-Keyboard-Handling.html#gdk-keymap-lookup-key If this behavior is not desired, the user has the option to check against num_layouts_for_key herself. https://bugs.freedesktop.org/show_bug.cgi?id=56866 Reported-by: Gatis Paeglis <gatis.paeglis@digia.com> Signed-off-by: Ran Benita <ran234@gmail.com>
2012-11-05keysym-utf: mark keysymtab array as staticRan Benita1-1/+1
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-11-05keysym-utf: also translate special keysyms like Tab and ReturnRan Benita1-25/+12
The keysym2ucs.c file apparently leaves out some keysyms, which libX11 deals with separately (like in _XkbHandleSpecialSym()). The problematic keysyms are the keypad ones (for which we already added some support) and keysyms which use 0xff** instead of 0x00** < 0x20. This code should fix them properly, as much as I could gather from libX11 and http://www.cl.cam.ac.uk/~mgk25/ucs/keysym2ucs.c and other sources (which are not aware of locale). https://bugs.freedesktop.org/show_bug.cgi?id=56780 Reported-by: Gatis Paeglis <gatis.paeglis@digia.com> Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-30action: don't allow private actions with a known typeRan Benita2-2/+21
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-29state, context: allow passing NULL to *_unref()Ran Benita2-2/+2
For error handling code, it's nice to be able to pass NULL to these function without worrying about segfaults ensuing. free() sets the precedent here. Also document this fact. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-26state: don't use xkb_keymap_num_layouts internallyRan Benita1-5/+3
Clearer and more greppable this way. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-26state: don't use xkb_state_serialize_* internallyRan Benita1-9/+3
The code in these cases is clearer when done directly. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-24state: fix possible index-out-of-bounds in action dispatch tableRan Benita1-0/+11
The current code assumes that action->type always falls in the range of the xkb_action_type enum. But keymaps can also have Private actions, which are allowed to set their own type number. So with a default xkeyboard-config keymap, keycode 86 at level 4, which triggers such an action, causes us to crash. Fix it by always checking the bounds. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-23keymap: use plain array for keymap->group_namesRan Benita4-24/+18
Again it is not resized. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-23state: fix typo in state component copyingRan Benita1-1/+1
Gladly no-one should have been fast enough to hit this. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-22Report which components of the state have changedRan Benita1-4/+45
We add a return value to the xkb_state_update_key and xkb_state_update_mask, which reports to the caller which of the state components have changed as a result. This restores the XKB functionality of the XkbStateNotify and XkbIndicatorsStateNotify events. See: http://www.x.org/releases/current/doc/kbproto/xkbproto.html#Events It is quite useful in some situations. For example, it allows an application to avoid doing some work if nothing of relevance in the state has changed. Say, a keyboard layout applet. Also useful for debugging. The deltas themselves are not provided, because I can't see a use case. If needed, it should be possible to add some API for that. In xkbcommon, keymaps are immutable, so all of the other *Notify events from XKB are irrelevant. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-22state: add struct state_componentsRan Benita1-68/+72
This holds all of the state component fields in the state in one struct. We will later want to keep the previous state components after updates, so this will allow us to do it without duplicating the fields. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-22Split the mods, layout, leds parts of xkb_state_componentsRan Benita5-39/+40
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>