summaryrefslogtreecommitdiff
path: root/src/keysym.c
Commit message (Collapse)AuthorAgeFilesLines
* build: include config.h manuallyRan Benita2019-12-271-0/+2
| | | | | | | | | Previously we included it with an `-include` compiler directive. But that's not portable. And it's better to be explicit anyway. Every .c file should have `include "config.h"` first thing. Signed-off-by: Ran Benita <ran@unusedvar.com>
* Use built-in istr[n]cmp() instead of strcase[n]cmp()Adrian Perez de Castro2019-12-271-1/+1
| | | | | | | This avoids the problem that MSVC does not provide strcasecmp() nor strncasecmp(), and at the same time avoids potential problems due to locale configuration by using istrcmp() and istrncmp() which are already in the source tree and written to cover only ASCII.
* keysym: handle ssharp in XConvertCase()Peter Hutterer2019-12-221-0/+4
| | | | | | | | | | | | | | | | | | | | | lowercase: LATIN SMALL LETTER SHARP S (U+00DF) uppercase: LATIN CAPITAL LETTER SHARP S (U+1E9E) The uppercase sharp s (XK_ssharp) is a relatively recent addition to unicode but was added to the relevant keyboard layouts in xkeyboard-config-2.25 (d1411e5e95c) https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/issues/144 Alas, the CapsLock behavior was broken on the finnish layout (maybe others). This was due XConvertCase() never returning the uppercase characters. Let's make this function return the right lower/upper symbols for the sharp s and hope that the world won't get any worse because of it. Corresponding Xlib issue: https://gitlab.freedesktop.org/xorg/lib/libx11/issues/110 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* keysym: add xkb_keysym_to_{lower,upper} to public APIRan Benita2017-12-111-2/+2
| | | | | | | | | | | | | | | | | | | These can be useful in some odd cases. There is already an implementation (+ tests) for internal use, so all that's needed is to export them. If xkbcommon were to provide a way to convert a Unicode codepoint to a keysym, this could have been implemented externally as follows: uint32_t codepoint = xkb_keysym_to_utf32(keysym); uint32_t upper_codepoint = my_unicode_library_to_upper(codepoint); xkb_keysym_t upper_keysym = theoretical_xkb_keysym_from_utf32(upper_codepoint); However keysym -> codepoint is not injective so such a function is not possible strictly speaking. Signed-off-by: Ran Benita <ran234@gmail.com>
* keysym: fix locale dependence in xkb_keysym_from_name()Ran Benita2016-12-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | 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>
* keysym: add function to test if a keysym is for a modifierRan Benita2014-10-031-0/+12
| | | | | | Needed for compose. Signed-off-by: Ran Benita <ran234@gmail.com>
* Remove unnecessary !!(expressions)Ran Benita2014-06-011-1/+1
| | | | | | _Bool already does that. Signed-off-by: Ran Benita <ran234@gmail.com>
* keysym: use safe keysym comparison functionRan Benita2014-02-081-1/+5
| | | | | | | Instead of thinking about signed <-> unsigned an whatnot. bsearch() is inline in glibc, so gcc optimizes this away anyway. Signed-off-by: Ran Benita <ran234@gmail.com>
* keysym: clarify slightly confusing comparison functionsRan Benita2014-01-021-2/+4
| | | | | | Make it clear what the search key type and array types are. Signed-off-by: Ran Benita <ran234@gmail.com>
* ks_tables: Put all keysym names in one giant blockJasper St. Pierre2014-01-011-14/+18
| | | | | This makes the file take two segments instead of potentially many, causing relocation issues.
* keysym: fix search for lexicographically larger stringsRan Benita2014-01-011-1/+1
| | | | | | Probably a copy/paste error from a few lines above. Signed-off-by: Ran Benita <ran234@gmail.com>
* keysym: add xkb_keysym_to_{lower,upper}Ran Benita2013-08-151-0/+20
| | | | | | | These functions are needed later; they are not API functions. The capitalization is not locale sensitive. 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>
* utils: add and use ARRAY_SIZE macroRan Benita2012-10-161-3/+3
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* Add xkb_keysym_from_name() flags argument for case-insensitive searchDavid Herrmann2012-10-161-6/+65
| | | | | | | | | | | | | | | | | | | | This adds a flags argument to xkb_keysym_from_name() so we can perform a case-insensitive search. This should really be supported as many keysyms have really weird capitalization-rules. However, as this may produce conflicts, users must be warned to only use this for fallback paths or error-recovery. This is also the reason why the internal XKB parsers still use the case-sensitive search. This also adds some test-cases so the expected results are really produced. The binary-size does _not_ change with this patch. However, case-sensitive search may be slightly slower with this patch. But this is barely measurable. [ran: use bool instead of int for icase, add a recommendation to the doc, and test a couple "thorny" cases.] Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
* makekeys: replace helper with python script and binary searchRan Benita2012-10-161-63/+32
| | | | | | | | | | | | | | | | | This removes the complicated and undocumented hash-table creation-helper and replaces it with an autogenerated sorted array. The search uses simple bsearch() now. We also tried using gperf but it turned out to generate way to big hashtables and when reducing the size it isn't really faster than bsearch() anymore. There are no users complaining about the speed of keysym lookups and we have no benchmarks that tell that we are horribly slow. Hence, we can safely use the simpler approach and drop all that old code. Signed-off-by: Ran Benita <ran234@gmail.com> Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
* keysym: fix xkb_keysym_is_upper/lower() to work properlyRan Benita2012-10-091-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>
* Add return value the xkb_keysym_get_nameRan Benita2012-09-241-8/+7
| | | | | | | | This is useful to see whether the function was successful and whether truncation occurred. It just changes void -> int so shouldn't break API or ABI. Signed-off-by: Ran Benita <ran234@gmail.com>
* Organize src/ and test/ headersRan Benita2012-09-161-5/+3
| | | | | | | | | | | | - 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>
* Copyright updatesDaniel Stone2012-09-121-1/+23
| | | | | | | | | | | | With Dan Nicholson's permission (via email), update his copyright and license statements to the standard X.Org boilerplate MIT license, as both myself and Ran have been using. Clean up my copyright declarations (in some cases to correct ownership), and add copyright/license statements from myself and/or Ran where appropriate. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* utils: add/replace string equality macrosRan Benita2012-07-271-1/+1
| | | | | | | | It's more tidy and less error prone, since we use strcasecmp == 0 a lot. We replace strcmp == 0 by streq, strcasecmp == 0 by istreq, uStrCasePrefix by istreq_prefix and uDupString by strdup_safe. Signed-off-by: Ran Benita <ran234@gmail.com>
* utils: remove Xfuncproto.h and use our own macrosRan Benita2012-07-231-2/+2
| | | | | | | Add XKB_EXPORT to replace _X_EXPORT, and copy the definitions of _X_ATTRIBUTE_FOO as ATTR_FOO. Signed-off-by: Ran Benita <ran234@gmail.com>
* Run source tree through uncrustifyDaniel Stone2012-07-171-38/+47
| | | | | | | .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>
* Rename KSIsLower/Upper and move to keysym.cRan Benita2012-07-131-0/+119
| | | | | | | Seems like a more natural place, and allows to remove the src/misc.c file. Signed-off-by: Ran Benita <ran234@gmail.com>
* Move XKB_KEY_NoSymbol to xkbcommon-keysyms.hRan Benita2012-06-091-6/+0
| | | | | | | | | This avoids a couple of special cases in the code, and is more consistent. Since anyone who includes xkbcommon.h also gets xkbcommon-keysyms.h, and anyone who include xkbcommon-keysyms.h would want NoSymbol anyway, there's no down side. Signed-off-by: Ran Benita <ran234@gmail.com>
* Merge remote-tracking branch 'krh/keysyms'Daniel Stone2012-05-091-9/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/keysym.c src/misc.c src/text.h src/xkbcomp/expr.c src/xkbcomp/parser.y src/xkbcomp/parseutils.c src/xkbcomp/symbols.c Signed-off-by: Daniel Stone <daniel@fooishbar.org>
| * Use our own keysymsKristian Høgsberg2012-05-091-9/+8
| |
* | Rename keysym <-> string APIDaniel Stone2012-05-091-3/+3
| | | | | | | | | | | | | | | | Change them to refer to the string representation of the keysym's name as a name rather than a string, since we want to add API to get the Unicode printable representation as well. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* | Rename XKBcommonint.h to xkb-priv.h and use itRan Benita2012-05-081-3/+2
|/ | | | | | | | | | Make the files in the src/* directory use their own header or a consilidated private header. This makes the file dependencies clearer. Also drop the pointless "xkb" file name prefix, add split a few declarations to their own files (atom.h and text.h). Signed-off-by: Ran Benita <ran234@gmail.com>
* Implicitly include config.h in all filesRan Benita2012-04-091-3/+0
| | | | | | | | | | | | | | | The definitions in config.h should be available in all files an implementation detail; it can be included through the build system instead of having each file pull it every time. This is especially helpful with AC_USE_SYSTEM_EXTENSIONS, as _GNU_SOURCE and friends can have an effect by merely being defined, which can lead to some confusion if its effective for only half the files. And we don't really support a build _without_ config.h; so, one less thing to worry about. Signed-off-by: Ran Benita <ran234@gmail.com>
* Remove Xfuncproto.h and XKB.h from xkbcommon/xkbcommon.hRan Benita2012-04-091-5/+6
| | | | | | | | | | | | | | | The kbproto header is already not needed here anymore. Move the _X_EXPORT's to the corresponding function definitions, and use straight extern "C" clauses instead of _XFUNCPROTOBEGIN/END. It also makes more sense to have the EXPORT's in the source files, as it provides some documentation to the reader, whereas in the header it's obvious. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Updated for xkb_keymap changes.]
* Eliminate remaining gcc warningsDaniel Stone2012-04-091-1/+1
| | | | | | | | | | | | | | | Various one-liners (mostly removing unused variables) to make the code safe for the full set of warnings used by the xorg macros. On Debian-based systems, flex generates incorrect code resulting in two warnings about yy_getcolumn and yy_setcolumn having no previous declaration despite being non-static. Fedora carries a patch to fix this, and a bug has been filed on Debian's flex to add the patch: http://bugs.debian.org/667027 Aside from this, it's now safe for --enable-strict-compilation. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* Don't parse nonsense Unicode/hex keycodesDaniel Stone2012-04-031-2/+9
| | | | | | | | If a keysym was specified as "U1039andsomeextrastuffontheend", return NoSymbol rather than 0x10001039; similarly, return NoSymbol for "0xdeadbeefhitherehowsyourdaybeen" rather than 0xdeadbeef. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* Define our own NoSymbol value and use itRan Benita2012-03-271-6/+5
| | | | | | | Since we have our own xkb_keysym_t type, it makes sense to have our own NoSymbol value instead of the one from X11/X.h. Signed-off-by: Ran Benita <ran234@gmail.com>
* Introduce xkb_keysym_t typeDaniel Stone2012-03-091-4/+4
| | | | Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* makekeys: update to match the rest of libX11 makekeysRan Benita2012-02-261-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This integrates two commits from libX11: ebd6ef0a4db0ddef0ae17ad14571518ccdeea5ba XStringToKeysym: Special case for XF86 keysyms Some XFree86 keysyms were in XKeysymDB as XF86_foo, despite really being XF86foo. So, if we get to the bottom of XStringToKeysym and haven't found our XF86_foo, try it again as XF86foo. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> 00175397480b76d32bf82b0c7c94c91a2a95954e makekeys: Scan vendor keysyms as well as core Since we can't really live without vendor keysyms, scan them all in to generate ks_tables.h, rather than only doing the core ones, and leaving the vendor syms to be manually synchronised with XKeysymDB. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Notice that the xkey.sh test is changed to match libX11 behavior, i.e. XKeysymToString(0x1008FE20) -> "XF86Ungrab" as opposed to "XF86_Ungrab". Signed-off-by: Ran Benita <ran234@gmail.com>
* makekeys: Fix build/target word size mismatch when cross-compilingRan Benita2012-02-261-1/+1
| | | | | | | | | | | | | | | | | | This matches commit 24283d40b1e4314c6647dda49d2a159833341a8b from libX11: Since makekeys is built using build environment's compiler and runs natively, we have to make sure that the size of the Signature type is the same on both the native environment and the target, otherwise we get mismatches upon running X, and some LSB test failures (xts5). Use an unsigned 32-bit integer on all platforms. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Ran Benita <ran234@gmail.com>
* Fix all constness warningsRan Benita2012-02-251-1/+1
| | | | | | These are all trivial/obvious fixes which clear a bunch of warnings. Signed-off-by: Ran Benita <ran234@gmail.com>
* Move include path from X11/extensions/ to xkbcommon/Daniel Stone2012-02-151-1/+1
| | | | Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* Don't return a static buffer in public APIKristian Høgsberg2010-10-081-18/+18
|
* Rename public entry points to lowercase and underscoreKristian Høgsberg2010-07-021-2/+2
|
* Fix warning from CARD32 -> uint32_t conversionKristian Høgsberg2010-06-301-1/+1
|
* Drop CARD32 and Opaque typesKristian Høgsberg2010-06-281-3/+3
|
* Use CARD32 instead of Atom, drag in XkbClientMapRecDaniel Stone2010-06-221-3/+3
| | | | | | | | | | | On 64-bit architectures, XID varies in size between the server (always 32 bits), and non-server (always unsigned long) for some inexplicable reason. Use CARD32 instead to avoid this horrible trap. This involves dragging in XkbClientMapRec so we don't get stuck in the KeySym trap. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* Keysym: Fix conversion for Unicode and bare numbersDaniel Stone2010-06-221-43/+13
| | | | | | | | | | Ensure that Unicode string representations are accepted and turned into numbers, as well as hexadecimal numbers in 0xabcd1234 form; unknown keysyms are output as 0xabcd1234 in string form. This also ensures that strings are never returned malloc()ed. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* KeySym: Actually handle NoSymbolDaniel Stone2009-04-251-3/+7
| | | | | | | | | Add NoSymbol into the keysym table, so keysym <-> string conversion works for that, too; also eliminate special-casing of VoidSymbol. This will require special-casing in libX11 to preserve its API. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* Remove all non-public API from XKBcommon.h headerDan Nicholson2009-04-081-0/+1
| | | | | | | | | | | | | The noble intention was to expose all the new API and new generic types in the split out kbproto headers through XKBcommon.h. It turns out that would be a massive amount of work in the server. Someday, but first just wedging in XkbCompileKeymap* would be good. Most of the API is in new internal xkb*.h headers. In order to allow the XKBcommon.h header to be used from the server, we can't pull in other headers from kbproto since the server has its own copies. However, types that are different (XkbDescRec, XkbAction) still have Xkbc equivalents here, and I think they should be used in the server.
* Rename headers to XKBcommon* and install in extensions directoryDan Nicholson2009-03-251-1/+1
| | | | | | Following the kbproto convention, the headers will be named XKBcommon.h and XKBcommonint.h. Furthermore, they'll be installed in X11/extensions directory with the rest of the XKB headers.
* keysym: Coding style cleanupDan Nicholson2009-03-191-67/+84
| | | | | | Mostly tab-to-space conversion plus a few style nits. Dropped the register keywords as I'm pretty sure modern compilers can be trusted to do the right thing.
* Initial implementation of keysym handlersDan Nicholson2009-03-191-0/+158
Add the xkbcommon implementations of XKeysymToString and XStringToKeysym. These symbols have the namespace prefix of Xkbc and are declared in X11/XkbCommon.h. The implementation is taken directly from Xlib, but does not include the XKeysymDB parsing and hashing yet (if it ever will). A couple type conversions were needed to keep from using Xlib.h. See original files: libX11/src/KeysymStr.c libX11/src/StrKeysym.c