summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* keycodes: don't do unnecessary copies while mergingRan Benita2013-03-181-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>
* state: small style fixRan Benita2013-03-181-11/+13
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* Move a couple of general keymap functions from keycodes.cRan Benita2013-03-186-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>
* keycodes: remove unneeded alias conflict checkRan Benita2013-03-181-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>
* xkbcomp: handle XKB file include's betterRan Benita2013-03-186-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>
* Build cleanly with clangRan Benita2013-03-182-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>
* keymap: abstract a bit over the keymap formatRan Benita2013-03-186-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>
* text: some style changesRan Benita2013-03-181-57/+53
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* text: clean up and fix the *MaskText functionsRan Benita2013-03-184-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>
* More spelling errorsRan Benita2013-03-184-5/+5
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* parser: also skip 'section' ELEMENTRan Benita2013-03-181-1/+1
| | | | | | It's for geometry only. Signed-off-by: Ran Benita <ran234@gmail.com>
* ast-build: remove malloc_or_dieRan Benita2013-03-181-82/+93
| | | | | | This should be fixed properly. Signed-off-by: Ran Benita <ran234@gmail.com>
* keycodes: fix spelling in error messageRan Benita2013-03-181-1/+1
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* Remove list.hRan Benita2013-03-181-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>
* keymap-dump: move writing 'key {}' in symbols to its own functionRan Benita2013-03-181-100/+107
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* keymap-dump: remove some ugly empty linesRan Benita2013-03-181-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>
* keymap-dump: don't indent after xkb_keymap {Ran Benita2013-03-181-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>
* keymap-dump: style cleanupsRan Benita2013-03-181-74/+45
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* ast: add error handling to XkbFileFromComponentsRan Benita2013-03-181-24/+32
| | | | | | And try to not repeat ourselves. Signed-off-by: Ran Benita <ran234@gmail.com>
* Fix dead assignmentsRan Benita2013-03-184-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>
* keysym: print unicode keysyms uppercase and 0-paddedRan Benita2013-03-181-3/+5
| | | | | | Use the same format as XKeysymToString. Signed-off-by: Ran Benita <ran234@gmail.com>
* Change some log functions to take ctx instead of keymapRan Benita2013-03-183-10/+10
| | | | | | They don't need the keymap, only the context. Signed-off-by: Ran Benita <ran234@gmail.com>
* keycodes: some minor styleRan Benita2013-03-181-18/+25
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* action: s/hndlrType/handler_typeRan Benita2013-03-181-5/+5
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* compat: make it clear which 'dflt' is meantRan Benita2013-03-181-19/+21
| | | | | | Also s/dflt/default. Signed-off-by: Ran Benita <ran234@gmail.com>
* symbols: make it clear which 'dflt' is meantRan Benita2013-03-181-18/+18
| | | | | | A bit easier at a glance. Also, vowels are cool, so just say 'default'. Signed-off-by: Ran Benita <ran234@gmail.com>
* ast: constify argumentRan Benita2013-03-182-2/+2
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* symbols: fix bad 'merge' assignmentRan Benita2013-03-181-1/+1
| | | | | | | Bug introduced in 2a5b0c9dc1ad1488ecc6b139fd70e464eb687da6, was causing some keys to be merged incorrectly. Signed-off-by: Ran Benita <ran234@gmail.com>
* Change 'indicator' to 'led' everywhere possibleRan Benita2013-03-1813-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>
* state: fix unbound virtual modifier bugRan Benita2013-03-181-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>
* Parser: Initialise geometry elements for VarDeclbaserock/morphDaniel Stone2012-12-061-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>
* state: rename state->cur to state->componentsRan Benita2012-11-111-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>
* state: don't keep the previous state components in xkb_stateRan Benita2012-11-111-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>
* keymap: wrap the layout parameter if it is out of range for the keyRan Benita2012-11-113-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>
* keysym-utf: mark keysymtab array as staticRan Benita2012-11-051-1/+1
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* keysym-utf: also translate special keysyms like Tab and ReturnRan Benita2012-11-051-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>
* action: don't allow private actions with a known typeRan Benita2012-10-302-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>
* state, context: allow passing NULL to *_unref()Ran Benita2012-10-292-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>
* state: don't use xkb_keymap_num_layouts internallyRan Benita2012-10-261-5/+3
| | | | | | Clearer and more greppable this way. Signed-off-by: Ran Benita <ran234@gmail.com>
* state: don't use xkb_state_serialize_* internallyRan Benita2012-10-261-9/+3
| | | | | | The code in these cases is clearer when done directly. Signed-off-by: Ran Benita <ran234@gmail.com>
* state: fix possible index-out-of-bounds in action dispatch tableRan Benita2012-10-241-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>
* keymap: use plain array for keymap->group_namesRan Benita2012-10-234-24/+18
| | | | | | Again it is not resized. Signed-off-by: Ran Benita <ran234@gmail.com>
* state: fix typo in state component copyingRan Benita2012-10-231-1/+1
| | | | | | Gladly no-one should have been fast enough to hit this. Signed-off-by: Ran Benita <ran234@gmail.com>
* Report which components of the state have changedRan Benita2012-10-221-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>
* state: add struct state_componentsRan Benita2012-10-221-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>
* Split the mods, layout, leds parts of xkb_state_componentsRan Benita2012-10-225-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>
* Silence a couple of warningsRan Benita2012-10-212-1/+4
| | | | | | These appear to come and go randomly. Signed-off-by: Ran Benita <ran234@gmail.com>
* Move _text() functions from keymap-dump to text.cRan Benita2012-10-183-77/+81
| | | | | | | | | 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>
* Remove a couple more uses of static char buffersRan Benita2012-10-182-6/+5
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* Contextualize GetBuffer()Ran Benita2012-10-186-32/+35
| | | | | | | 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>