summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Make path retrieval consistent in xkb_compose_table_new_from_locale()Emmanuel Gil Peyrot2020-07-233-15/+13
|
* compose: add xdg base directory supportEmmanuel Gil Peyrot2020-07-233-0/+29
| | | | | | | Before reading ~/.XCompose, try to read $XDG_CONFIG_HOME/XCompose (falling back to ~/.config/XCompose). This helps unclutter the home directory of users who want that.
* xkbcomp: return NULL, not false in place of a FILE*Peter Hutterer2020-07-131-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* xkbcomp: simplify buffer handling in the include handlingPeter Hutterer2020-07-131-23/+9
| | | | | | | | Don't do the realloc dance, just asprintf to the buffer and move on. The check is likely pointless anyway, if we run out of asprintf size, log_error will probably blow up as well. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add asprintf_safe helper functionPeter Hutterer2020-07-134-24/+47
| | | | | | | We only ever care about whether we error out or not, so let's wrap this into something more sane. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* context: log include paths for debuggingPeter Hutterer2020-07-081-3/+12
| | | | | | | Now that we're relying on various different include paths, let's log that ones we use and the ones we failed to use. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* meson.build: always set the default variants/optionsPeter Hutterer2020-07-081-8/+0
| | | | | | | Make this more balanced with the rules/layouts so we can rely on that #define to exist. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add libxkbregistry to query available RMLVOPeter Hutterer2020-07-064-0/+1361
| | | | | | | | | | | | | | | | | | | | | This library is the replacement for clients parsing evdev.xml directly. Instead, they should use the API here so that in the future we may even be able to swap evdev.xml for a more suitable data format. The library parses through evdev.xml (using libxml2) and - if requested - through evdev.extras.xml as well. The merge approach is optimised for the default case where we have a system-installed rules XML and another file in $XDG_CONFIG_DIR that adds a few entries. We load the system file first, then append any custom ones to that. It's not possible to overwrite the MLVO list provided by the system files - if you want to do that, get the change upstream. XML validation is handled through the DTD itself which means we only need to check for a nonempty name, everything else the DTD validation should complain about. The logging system is effectively identical to xkbcommon. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* utils: add streq_null() for streq that allows NULL valuesPeter Hutterer2020-07-061-0/+8
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Add a snprintf_safe() helper functionPeter Hutterer2020-07-061-0/+15
| | | | | | | Returns true on success or false on error _or_ truncation. Since truncation is almost always an error anyway, we might as well make this easier to check. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Factor the access check for paths outPeter Hutterer2020-07-062-6/+24
| | | | | | Easier to re-use without having to duplicate ifdefs. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* keysyms: add XKB_KEY_XF86FullScreenRan Benita2020-05-201-327/+330
| | | | | | | Updated using ./scripts/update-keysyms using latest xorgproto. Fixes: https://github.com/xkbcommon/libxkbcommon/issues/147 Signed-off-by: Ran Benita <ran@unusedvar.com>
* keymap: don't forget about fallback mappings in ↵Ran Benita2020-04-181-3/+30
| | | | | | | | | | | | | | | | | | | | xkb_keymap_key_get_mods_for_level() If the active set of modifiers doesn't match any explicit entry of the key type, the resulting level is 0 (i.e. Level 1). Some key types don't explicitly map Level 1, taking advantage of this fallback. Previously, xkb_keymap_key_get_mods_for_level didn't consider this, and only reported masks for explicit mappings. But this causes some glaring omissions, like matching "a" in the "us" keymap returning not results. Since every mask which isn't explicitly mapped falls back to 0, we can't return the all. Almost always the best choice for this is the empty mask, so return that, when applicable. Fixes https://github.com/xkbcommon/libxkbcommon/issues/140. Reported-by: https://github.com/AliKet Signed-off-by: Ran Benita <ran@unusedvar.com>
* API to query modifier set required to type a keysymJaroslaw Kubik2020-03-203-11/+44
| | | | | | | | | The new API is useful to implement features like auto-type and desktop automation. Since the inputs for these features is usually specified in terms of the symbols that need to be typed, the implementation needs to be able to invert the keycode->keysym transformation and produce a sequence of keycodes that can be used to type the requested character(s).
* Support translation Unicode codepoints to keysymsJaroslaw Kubik2020-02-241-0/+29
| | | | | | | | | In order to support features like auto-type and UI automation, the relevant tools need to be able to invert the keycode->keysym->text transformation. In order to facilitate that, a new API was added. It allows querying the keysyms that correspond to particular Unicode codepoints. For all practical purposes, it can be thought of as an inverse of xkb_keysym_to_utf32().
* MSVC: Use <io.h> as an alternative for <unistd.h>Adrian Perez de Castro2019-12-282-2/+9
| | | | | | | | | Only the input/output functions from <unistd.h> options are used, so using <io.h> when building with MSVC should be enough. The inclusion of the header in context-priv.c does not seem to be needed (tested on GNU/Linux) and so it is removed. Signed-off-by: Ran Benita <ran@unusedvar.com>
* xkbcomp/rules: support \r\n line endingsRan Benita2019-12-281-1/+3
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* Open files in binary modeRan Benita2019-12-285-7/+7
| | | | | | This turns off some misfeatures on Windows, and does nothing on POSIX. Signed-off-by: Ran Benita <ran@unusedvar.com>
* xkbcomp: remove cast which triggers warning on gccRan Benita2019-12-271-1/+1
| | | | | | Will need some other way to take care of the warning on MSVC. Signed-off-by: Ran Benita <ran@unusedvar.com>
* xkbcomp: make a couple of casts explicit to mark them as checkedRan Benita2019-12-272-2/+5
| | | | | | This acknowledges some "possible loss of data cast" warnings from MSVC. Signed-off-by: Ran Benita <ran@unusedvar.com>
* xkbcomp/keywords: regenerate with newer gperfRan Benita2019-12-273-70/+109
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* parser: fix format string for int64_tRan Benita2019-12-271-1/+1
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* Only add GCC diagnostic pragmas when compiler is GCC compatibleRan Benita2019-12-271-0/+4
| | | | | | Avoid "unknown pragma" warnings on other compilers. Signed-off-by: Ran Benita <ran@unusedvar.com>
* xkbcomp: fix wrong return typeRan Benita2019-12-271-1/+1
| | | | | | | | Detected by MSVC: xkbcomp\xkbcomp.c(111): warning C4047: 'return': 'bool' differs in levels of indirection from 'void *' Signed-off-by: Ran Benita <ran@unusedvar.com>
* parser: use int64_t for all numbersRan Benita2019-12-271-6/+4
| | | | | | | | | | | Don't use int which can have different size on different machines. Also avoid some warnings from MSVC: xkbcomp/parser.y(760): warning C4244: '=': conversion from 'int64_t' to 'int', possible loss of data xkbcomp/parser.y(761): warning C4244: '=': conversion from 'int64_t' to 'int', possible loss of data xkbcomp/parser.y(767): warning C4244: '=': conversion from 'int64_t' to 'int', possible loss of data Signed-off-by: Ran Benita <ran@unusedvar.com>
* scanner-utils: avoid possible implicit truncating of line/columnRan Benita2019-12-271-3/+3
| | | | | | | | | | | This increases the size of the struct a bit but it's not very important. Fixes these MSVC warnings: src\scanner-utils.h(112): warning C4267: '+=': conversion from 'size_t' to 'unsigned int', possible loss of data src\scanner-utils.h(147): warning C4267: '+=': conversion from 'size_t' to 'unsigned int', possible loss of data Signed-off-by: Ran Benita <ran@unusedvar.com>
* utils: move macro defines to before they're usedRan Benita2019-12-271-8/+8
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* utils: fix typo in strndup fallbackRan Benita2019-12-271-1/+1
| | | | | | Fixup 93a1305 - we will have CI for this soon. Signed-off-by: Ran Benita <ran@unusedvar.com>
* build: include config.h manuallyRan Benita2019-12-2734-0/+67
| | | | | | | | | 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>
* Provide a fallback implementation of [v]asprintf()Adrian Perez de Castro2019-12-272-0/+53
| | | | | | Some environments (e.g. Windows + MSVC) do not provide asprintf() or vasprintf(). This tries to detect their presence, and provides suitable fallback implementations when not available.
* Provide a fallback implementation of strndup()Adrian Perez de Castro2019-12-271-0/+15
| | | | | | | | Some environments (e.g. Windows + MSVC) do not provide strndup(), this tries to detect its presence and provide a fallback implementation when not available. [ran: some tweaks]
* 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.
* utils: use MIN/MAX instead of min/maxRan Benita2019-12-273-17/+3
| | | | | | min/max symbols conflict on some systems (msvc), so just use the macros. Signed-off-by: Ran Benita <ran@unusedvar.com>
* xkbcomp: downgrade "Symbol added to modifier map for multiple modifiers" log ↵Ran Benita2019-12-271-12/+12
| | | | | | | | | | | | | | | | to a warning This condition happens in xkeyboard-config keymaps and seems hard to fix. Currently it incessantly spams people's logs who have no idea what to do about it. So downgrade to "warning" level, so it doesn't show up by default. When working on keymaps, set `XKB_LOG_LEVEL=debug XKB_LOG_VERBOSITY=10` to see all possible messages. Refs https://github.com/xkbcommon/libxkbcommon/issues/111 Fixes https://github.com/xkbcommon/libxkbcommon/issues/128 Signed-off-by: Ran Benita <ran@unusedvar.com>
* rules: eliminate an extra fopen/fclose cyclePeter Hutterer2019-12-241-15/+15
| | | | | | | | FindXkbFileInPath() opens the file so we're guaranteed that the file not only exists, but that we can read it. Changing that would alter behavior so instead let's just pass that file handle along and do the same for include files. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* rules: add include statements to rules filesPeter Hutterer2019-12-241-2/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The majority use-case for extending XKB on a machine is to override one or a few keys with custom keycodes, not to define whole layouts. Previously, we relied on the rules file to be a single file, making it hard to extend. libxkbcommon parses $XDG_CONFIG_HOME/xkb/ but that only works as long as there is a rule that matches the user-specified RMLVO. This works for MLV but not for options which don't have a wildcard defined. Users have to copy the whole rules file and then work from there - not something easy to extend and maintain. This patch adds a new ! include directive to rules files that allows including another file. The file path must be without quotes and may not start with the literal "include". Two directives are supported, %H to $HOME and %S for the system-installed rules directory (usually /usr/share/X11/xkb/rules). A user would typically use a custom rules file like this: ! option = symbols custom:foo = +custom(foo) custom:bar = +custom(baz) ! include %S/evdev Where the above defines the two options and then includes the system-installed evdev rule. Since most current implementations default to loading the "evdev" ruleset, it's best to name this $XDG_CONFIG_HOME/xkb/rules/evdev, but any valid name is allowed. The include functionally replaces the line with the content of the included file which means the behavior of rules files is maintained. Specifically, custom options must be defined before including another file because the first match usually wins. In other words, the following ruleset will not assign my_model as one would expect: ! include %S/evdev ! model = symbols my_model = +custom(foo) The default evdev ruleset has wildcards for model and those match before the my_model is hit. The actual resolved components need only be in one of the XKB lookup directories, e.g. for the example above: $ cat $XDG_CONFIG_HOME/xkb/symbols/custom partial alphanumeric_keys xkb_symbols "foo" { key <TLDE> { [ VoidSymbol ] }; }; partial alphanumeric_keys xkb_symbols "baz" { key <AB01> { [ k, K ] }; }; This can then be loaded with the XKB option "custom:foo,custom:bar". The use of "custom" is just as an example, there are no naming requirements beyond avoiding already-used ones. Also note the bar/baz above - the option names don't have to match the component names. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* context: add a helper function to return the default system include pathPeter Hutterer2019-12-242-5/+12
| | | | | | | No functional changes but we'll need that same lookup in the rules file include handling in a future patch. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* rules: move the matcher result handling to the callerPeter Hutterer2019-12-241-38/+37
| | | | | | | | This shouldn't be processed in the matcher itself, especially in the glorious future when we can have nested matchers. Only handle this once in the caller to the original parsed file. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* rules: put the scanner on the stackPeter Hutterer2019-12-241-58/+65
| | | | | | This allows nesting the scanner for the future !include directive. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* rules: simplify an error pathPeter Hutterer2019-12-241-3/+3
| | | | | | | Initialize to NULL so we don't have to care about whether the cleanups can be called or not. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* rules: rename a variable from 's' to 'str'Peter Hutterer2019-12-241-11/+11
| | | | | | To avoid name conflicts with a future patch. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* rules: drop the matcher_err() macro and use scanner_err directlyPeter Hutterer2019-12-241-17/+14
| | | | | | | No functional changes, this is what the macro expanded to anyway. Prep work for putting the scanner on the stack and removing it from the matcher struct. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* rules: factor out the function to parse a rules filePeter Hutterer2019-12-241-13/+36
| | | | | | | No functional changes, this just makes the part to parse a single rules file re-usable. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* 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>
* parser: fix the remaining pointer chasingRan Benita2019-12-141-22/+21
| | | | | | Fix the TODO added in 7c42945. Signed-off-by: Ran Benita <ran@unusedvar.com>
* parser: fix quadratic pointer chasingRan Benita2019-11-143-61/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the AST, lists (e.g. the list of statements in a file) are kept in singly-linked lists -- each AST node has a `next` pointer available for this purpose. Previously, a node was added to the list by starting from the head, chasing to the last, and appending. So creating a list of length N would take ~N^2/2 pointer dereferences. Now, we always (temporarily) keep the last as well, so appending is O(1) instead of O(N). Given a keymap xkb_keymap { xkb_keycodes { minimum = 8; minimum = 8; minimum = 8; minimum = 8; minimum = 8; [... repeated N times ...] }; xkb_types {}; xkb_compat {}; xkb_symbols {}; }; The compilation times are N | Before | After --------|----------|------- 10,000 | 0.407s | 0.006s 20,000 | 1.851s | 0.015s 30,000 | 5.737s | 0.021s 40,000 | 12.759s | 0.023s 50,000 | 21.489s | 0.035s 60,000 | 40.473s | 0.041s 70,000 | 53.336s | 0.039s 80,000 | 72.485s | 0.044s 90,000 | 94.703s | 0.048s 100,000 | 118.390s | 0.057s Another option is to ditch the linked lists and use arrays instead. I got it to work, but its more involved and allocation heavy so turns out to be worse without further optimizations. Signed-off-by: Ran Benita <ran@unusedvar.com>
* parser: remove an unneeded checkRan Benita2019-11-141-7/+2
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* compat: reject interpret modifier predicate with more than one valueRan Benita2019-11-121-1/+1
| | | | | | | | | | Given interpret ISO_Level3_Shift+AnyOf(all,extraneous) { ... }; Previously, extraneous (and further) was ignored. Now it's rejected. Signed-off-by: Ran Benita <ran@unusedvar.com>
* expr: fix log message on some unexpected expression typesRan Benita2019-11-121-0/+6
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* Replace some tabs that sneaked in with spacesRan Benita2019-11-122-6/+6
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>