summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* x11/keymap,test/interactive-evdev: fix a couple of clang-analyzer warningsRan Benita2017-07-311-0/+1
| | | | | | | From my analysis these values cannot be null, but the analyzer cannot see this. So assert it. Signed-off-by: Ran Benita <ran234@gmail.com>
* Sync Keysyms with recent xproto additionsHans de Goede2017-05-121-393/+405
| | | | | | | | | | | | | xproto recently has been extended with 4 new keysyms: XF86XK_Keyboard XF86XK_WWAN XF86XK_RFKill XF86XK_AudioPreset This commit is the result of running "make update-keysyms" on a system with the updated xproto installed. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* state: cure boolean blindness in the filter functions' resultRan Benita2017-04-271-24/+41
| | | | | | Makes it a little easier to understand the filters. Signed-off-by: Ran Benita <ran234@gmail.com>
* state: remove unneeded NULL checkRan Benita2017-04-271-3/+0
| | | | | | xkb_filter_new() cannot return NULL. Signed-off-by: Ran Benita <ran234@gmail.com>
* state: reorder new() functions before the set() functions in the codeRan Benita2017-04-271-28/+28
| | | | | | So that they may be read more naturally in chronological order. Signed-off-by: Ran Benita <ran234@gmail.com>
* Add explicit fallthrough case statementsDaniel Stone2017-04-112-1/+2
| | | | | | | When we fall through to another label in a case, add an explicit comment noting so, to quiet GCC 7's warnings. Signed-off-by: Daniel Stone <daniels@collabora.com>
* compose: remove the keysym_from_name cacheRan Benita2016-12-031-45/+3
| | | | | | | | | | The hit rate is high, but either the cache is slow or the function is not fast enough -- the cache no longer holds its weight, leading only to very modest improvements. If it's the former, it can definitely be improved, the code is very dumb (though it worked just as well as any other I tried back then). But instead, let's just kill it. Signed-off-by: Ran Benita <ran234@gmail.com>
* keysym: fix locale dependence in xkb_keysym_from_name()Ran Benita2016-12-023-7/+68
| | | | | | | | | | | | | | | | | | | | | | | We currently use strcasecmp, which is locale-dependent. In particular, one well-known surprise even if restricted just ASCII input is found in the tr_TR (Turkish) locale, see e.g. https://msdn.microsoft.com/en-us/library/ms973919.aspx#stringsinnet20_topic5 We have known to avoid locale-dependent functions before, but in this case, we forgot. Fix it by implementing our own simple ASCII-only strcasecmp/strncasecmp. Might have been possible to use strcasecmp_l() with the C locale, but went the easy route. Side advantage is that even this non-optimized version is faster than the optimized libc one (__strcasecmp_l_sse42) since it doesn't need to do the locale stuff. xkb_keysym_from_name(), which uses strcasecmp heavily, becomes faster, and so for example Compose file parsing, which uses xkb_keysym_from_name() heavily, becomes ~20% faster. Resolves https://github.com/xkbcommon/libxkbcommon/issues/42 Signed-off-by: Ran Benita <ran234@gmail.com>
* utils: rename popcount to avoid conflict in NetBSDRan Benita2016-11-142-2/+3
| | | | | Resolves https://github.com/xkbcommon/libxkbcommon/issues/41 Signed-off-by: Ran Benita <ran234@gmail.com>
* state: add GTK consumed modifiers modeRan Benita2016-10-311-0/+25
| | | | | | | | | | | | | | | | This is more or less what is implemented here: https://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkkeys-x11.c?h=3.19.10#n1131 The implementation here is more technically correct but should provide the same results. Try it out with ./test/interactive-evdev -g (modifiers prefixed with "-" are consumed). https://bugzilla.gnome.org/show_bug.cgi?id=754110 https://github.com/xkbcommon/libxkbcommon/issues/17 Signed-off-by: Ran Benita <ran234@gmail.com>
* state: allow different modes for calculating consumed modifiersRan Benita2016-10-311-36/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The current functions dealing with consumed modifiers use the traditional XKB definition of consumed modifiers (see description in the added documentation). However, for several users of the library (e.g. GTK) this definition is unsuitable or too eager. This is exacerbated by some less-than-ideal xkeyboard-config type definitions (CTRL+ALT seems to cause most grief...). So, because we - want to enable alternative interpretations, but - don't want to expose too much internal details, and - want to keep things simple for all library users, we add a high-level "mode" parameter which selects the desired interpretation. New ones can be added as long as they make some sense. All of the old consumed-modifiers functions keep using the traditional ("XKB") mode. I mark xkb_state_mod_mask_remove_consumed() and as deprecated without adding a *2 variant because I don't it is very useful (or used) in practice. Alternative modes are added in subsequent commits (this commit only adds a mode for the existing behavior). https://github.com/xkbcommon/libxkbcommon/issues/17 Signed-off-by: Ran Benita <ran234@gmail.com>
* utils: add popcount functionRan Benita2016-10-221-0/+13
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* keymap-dump: use consistent order set/latch/lock (style)Ran Benita2016-06-091-1/+1
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* src/state: match_mod_masks can return bool instead of intRan Benita2016-06-091-6/+4
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* src/utils: check if fileno() failed in map_fileRan Benita2016-03-131-1/+4
| | | | | | | | | | | | | | | | fileno() can fail, if called on e.g. fmemopen() FILEs which are not backed by a file descriptor. This functions uses mmap to map the entire file to memory, so using such FILEs will not work. (There is actually no change of behavior here, since the following fstat would have already failed with EBADF. But lets make it clear.) Another possibility is to fall back to the !HAVE_MMAP case; but it sounds like a better idea to leave it to the programmer to use the new_from_string/new_from_buffer functions instead, instead of doing double allocation behind their back. Signed-off-by: Ran Benita <ran234@gmail.com>
* keymap: share LevelsSameSyms()Ran Benita2016-02-283-14/+14
| | | | | | The function is generic enough. Signed-off-by: Ran Benita <ran234@gmail.com>
* state: factor out get_entry_for_mods()Ran Benita2016-02-281-7/+11
| | | | | | Will be useful later. Signed-off-by: Ran Benita <ran234@gmail.com>
* state: factor out entry_is_active() checkRan Benita2016-02-281-11/+14
| | | | | | | Makes the code slightly cleaner and I plan to use the function in another place. Signed-off-by: Ran Benita <ran234@gmail.com>
* keymap: add xkb_keymap_key_by_name(), xkb_keymap_key_get_name(), testsMike Blumenkrantz2016-01-201-0/+34
| | | | | | | | | | | | xkb_keymap_key_by_name() allows finding a keycode from a given keyname and is useful for generating keyboard events to use in regression tests during CI xkb_keymap_key_get_name() is the inverse of xkb_keymap_key_by_name() Signed-off-by: Mike Blumenkrantz <zmike@osg.samsung.com> [ran: some stylistic tweaks + another test case] Signed-off-by: Ran Benita <ran234@gmail.com>
* src/utils: change map_file to not take const string argumentRan Benita2015-11-196-13/+14
| | | | | | | | | map_file() uses PROT_READ, so const seems fitting; however unmap_file calls munmap/free, which do not take const, so an UNCONSTIFY is needed. To avoid the UNCONSTIFY hack, which is likely undefined behavior or some such, just remove the const. Signed-off-by: Ran Benita <ran234@gmail.com>
* keymap: fix outdated commentRan Benita2015-10-261-1/+1
| | | | | | See 725ae134d434bab6c999121d55dbc3582c4acb65. Signed-off-by: Ran Benita <ran234@gmail.com>
* state: reduce scope of fake actionRan Benita2015-09-071-4/+4
| | | | | | Also rename to "dummy" as I think it is a nicer name. Signed-off-by: Ran Benita <ran234@gmail.com>
* Add XKB_CONFIG_ROOT environmentMichael Vogt2015-07-201-2/+6
| | | | | The XKB_CONFIG_ROOT environment allows overrding the build time DFLT_XKB_CONFIG_ROOT path.
* compose: correctly parse modifier syntaxRan Benita2015-03-241-17/+24
| | | | | | | As described in: http://cgit.freedesktop.org/xorg/lib/libX11/commit/?id=ddf3b09bb262d01b56fbaade421ac85b0e60a69f Signed-off-by: Ran Benita <ran234@gmail.com>
* keycodes: use correct printf formatRan Benita2014-10-231-1/+1
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* Reduce variable scopesRan Benita2014-10-235-17/+12
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* ast-build: remove log message about allocation failureRan Benita2014-10-181-5/+1
| | | | | | | We don't do so anywhere else, so until we have something comprehensive, let's not so here. Signed-off-by: Ran Benita <ran234@gmail.com>
* xkbcomp: remove file->topNameRan Benita2014-10-187-15/+6
| | | | | | It is useless. Signed-off-by: Ran Benita <ran234@gmail.com>
* xkbcomp/keymap: remove useless free()Ran Benita2014-10-181-3/+1
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* Replace some strncmp's with memcmpRan Benita2014-10-182-4/+4
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* compose/parser: save len in keysym_from_name cacheRan Benita2014-10-181-1/+4
| | | | | | This reduces a lot of strcmp's, and allows to use a faster memcmp. Signed-off-by: Ran Benita <ran234@gmail.com>
* state: correctly infer inactive type entriesRan Benita2014-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | The current test is incorrect, since 'map[None]' is entirely valid. In most cases this doesn't cause any problems, since the default fallback is Level1, and it's almost always 'map[None] = Level1' anyway. But in one case in xkeyboard-config it isn't, in types/numpad(mac): type "KEYPAD" { modifiers = None; map[None] = Level2; level_name[Level2] = "Number"; }; So before checking if no modifiers were mapped, make sure there *were* any modifiers at all. https://bugs.freedesktop.org/show_bug.cgi?id=85092 Reported-by: Gatis Paeglis <gatis.paeglis@digia.com> Signed-off-by: Ran Benita <ran234@gmail.com>
* symbols: don't warn about conflicting syms if they are the sameRan Benita2014-10-171-1/+14
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* parser: bring back warning about includes of files with no defaultRan Benita2014-10-171-0/+6
| | | | | | Using the same format as xkbcomp. Signed-off-by: Ran Benita <ran234@gmail.com>
* compose/parser: fix parsing of multiple modifiersRan Benita2014-10-141-13/+20
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* compose/parser: parse (! mods) properlyRan Benita2014-10-131-15/+91
| | | | | | | We don't actually do anything with them. But if someone uses them we can at least not choke. Signed-off-by: Ran Benita <ran234@gmail.com>
* compose/parser: resolve keysyms in parser instead of scannerRan Benita2014-10-131-28/+38
| | | | | | It will become context-sensitive. Signed-off-by: Ran Benita <ran234@gmail.com>
* compose/parser: use parameter as intendedRan Benita2014-10-131-1/+1
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* compose/parser: one more skip_to_eol()Ran Benita2014-10-131-3/+2
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* compose/parser: fix segfault when includingRan Benita2014-10-134-6/+7
| | | | | | | | The keysym cache for the new scanner was not initialized. To avoid such errors also in the future, require passing the priv argument in scanner_init(), instead of initializing it separately. Signed-off-by: Ran Benita <ran234@gmail.com>
* COPYING: add copyright notice from libX11:modules/im/ximcp/imLcPrs.cRan Benita2014-10-131-0/+31
| | | | | | We have used some portions of it, so add the notice. Signed-off-by: Ran Benita <ran234@gmail.com>
* scanner-utils: optimize one-line commentsRan Benita2014-10-084-3/+12
| | | | | | Compose files have a lot of those. Signed-off-by: Ran Benita <ran234@gmail.com>
* compose: add xkbcommon-compose - implementationRan Benita2014-10-057-0/+1431
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* scanner-utils: add priv memberRan Benita2014-10-031-0/+1
| | | | | | For when a user of the scanner wants to pass something along with it. Signed-off-by: Ran Benita <ran234@gmail.com>
* darray: add darray_shrink()Ran Benita2014-10-031-0/+6
| | | | | | | If we have a big array which can be finalized, on average we can give back 1/4 of its size, which the allocator might be able to use. Signed-off-by: Ran Benita <ran234@gmail.com>
* keysym: add function to test if a keysym is for a modifierRan Benita2014-10-032-0/+15
| | | | | | Needed for compose. Signed-off-by: Ran Benita <ran234@gmail.com>
* scanner-utils: add helper for appending an entire stringRan Benita2014-10-021-0/+11
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* scanner-utils: add helper for hex string escapeRan Benita2014-10-021-0/+13
| | | | | | Like the already existing oct. Signed-off-by: Ran Benita <ran234@gmail.com>
* scanner-utils: optimize str()/lit()Ran Benita2014-10-011-1/+1
| | | | | | | | | | | | Replace the dog-slow unneeded strncasecmp() with an inlineable memcmp(). Before: compiled 2500 keymaps in 8.348715629s After: compiled 2500 keymaps in 7.872640338s Signed-off-by: Ran Benita <ran234@gmail.com>
* keymap: rename XkbKeyGroupWidth to XkbKeyNumLevelsRan Benita2014-09-255-10/+9
| | | | | | | | The "width" terminology comes from the group*width+level layout of the keysyms in a key, as used in the old implementations. We don't keep all the keysyms of a key in one array so change it to a more accurate name. Signed-off-by: Ran Benita <ran234@gmail.com>