summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* interactive-wayland: fallback to ftruncate() if neededEvgeniy Khramtsov2021-04-141-11/+24
| | | | | | | | | | Fallback to ftruncate() if the underlying filesystem does not support posix_fallocate(). Idea by: Jan Beich <jbeich@FreeBSD.org>, Niclas Zeising <zeising@FreeBSD.org> Inspired by: Wayland cursor/os-compatibility.c [ran: small adjustments] Signed-off-by: Ran Benita <ran@unusedvar.com>
* doc: fix user-configuration sample fileJouke Witteveen2021-04-111-1/+3
| | | | | | Support copy-pasting from the docs to get something functional. Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com>
* scripts: update license note in perfect_hash.pyRan Benita2021-04-081-4/+4
| | | | | | Ref: https://github.com/ilanschnell/perfect-hash/issues/5 Signed-off-by: Ran Benita <ran@unusedvar.com>
* Bump version to 1.2.1xkbcommon-1.2.1Ran Benita2021-04-072-1/+8
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* x11: fix xkb_x11_keymap_new_from_device failing when a level name is emptyRan Benita2021-04-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | The numpad:mac option doesn't specify a name for the first level: // On Mac keypads, level 1 and 2 are swapped. partial xkb_types "mac" { type "KEYPAD" { modifiers = None; map[None] = Level2; level_name[Level2] = "Number"; }; include "extra(keypad)" }; This means the atom for level name is XCB_ATOM_NONE. We tried to get its name, which fails. This regressed in 40c00b472144d1684d2fb97cafef39. Instead, translate it to XKB_ATOM_NONE, same as the previous behavior. Fixes: https://github.com/xkbcommon/libxkbcommon/issues/229 Signed-off-by: Ran Benita <ran@unusedvar.com>
* Bump version to 1.2.0xkbcommon-1.2.0Ran Benita2021-04-032-1/+27
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* compose: fix max compose nodes checkRan Benita2021-04-021-2/+3
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* keysym: speed up the perfect hash functionRan Benita2021-04-012-298/+301
| | | | | | | | | | | | | Make it use a bit operation instead of an expensive modulo. perf diff: Baseline Delta Abs Shared Object Symbol ........ ......... ................. ................................... 28.15% -6.57% bench-compose [.] xkb_keysym_from_name Signed-off-by: Ran Benita <ran@unusedvar.com>
* keysym: avoid strtoul in xkb_keysym_from_nameRan Benita2021-04-012-10/+39
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* keysym: use a perfect hash function for case sensitive xkb_keysym_from_nameRan Benita2021-04-014-2577/+1036
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 7d84809fdccbb5898d0838849ec7c321410182d5 I added a fast path for the case-sensitive case, but it is still slowing down Compose parsing. Instead of the binary search, use a perfect hash function, computed with a simple python module I found (vendored). It is faster -- perf diff is: Baseline Delta Abs Shared Object Symbol ........ ......... ................. ................................... 22.35% -14.04% libc-2.33.so [.] __strcmp_avx2 16.75% +10.28% bench-compose [.] xkb_keysym_from_name 20.72% +2.40% bench-compose [.] parse.constprop.0 2.29% -1.97% bench-compose [.] strcmp@plt 2.56% +1.81% bench-compose [.] resolve_name 2.37% +0.92% libc-2.33.so [.] __GI_____strtoull_l_internal 26.19% -0.63% bench-compose [.] lex 1.45% +0.56% libc-2.33.so [.] __memchr_avx2 1.13% -0.31% libc-2.33.so [.] __strcpy_avx2 Also reduces the binary size: Before: text data bss dec hex filename 341111 5064 8 346183 54847 build/libxkbcommon.so.0.0.0 After: text data bss dec hex filename 330215 5064 8 335287 51db7 build/libxkbcommon.so.0.0.0 Note however that it's still larger than before 7d84809fdccbb5898d08388: text data bss dec hex filename 320617 5168 8 325793 4f8a1 build/libxkbcommon.so.0.0.0 Signed-off-by: Ran Benita <ran@unusedvar.com>
* compose: use a ternary tree instead of a regular trieRan Benita2021-03-314-128/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we used a simple trie with a linked list for each chain. Unfortunately most compose files have very long chains which means the constructions performs an almost quadratic number of comparisons. Switch to using a ternary search tree instead. This is very similar to a trie, only the linked list is essentially replaced with a binary tree. On the en_US/Compose file, the perf diff is the following (the modified function is `parse`): Event 'cycles:u' Baseline Delta Abs Shared Object Symbol ........ ......... ................ ................................. 39.91% -17.62% bench-compose [.] parse.constprop.0 20.54% +6.47% bench-compose [.] lex 17.28% +5.55% libc-2.33.so [.] __strcmp_avx2 12.78% +4.01% bench-compose [.] xkb_keysym_from_name 2.30% +0.83% libc-2.33.so [.] __GI_____strtoull_l_internal 3.36% +0.78% bench-compose [.] strcmp@plt Thanks to some careful packing, the memory usage is pretty much the same. Signed-off-by: Ran Benita <ran@unusedvar.com>
* ast: remove comment re. anonymous structRan Benita2021-03-301-1/+0
| | | | | | | C11 is not sufficient for this, needs `--ms-extensions` which we don't want to enable. Signed-off-by: Ran Benita <ran@unusedvar.com>
* compose: use anonymous unionRan Benita2021-03-304-25/+27
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* build: require C11Ran Benita2021-03-301-1/+1
| | | | | | | I'd really like to use anonymous unions/structs. Supposedly even MSVC supports it now. Let's try and see. Signed-off-by: Ran Benita <ran@unusedvar.com>
* keysym: properly handle overflow in 0x keysym namesRan Benita2021-03-302-6/+14
| | | | | | | | Relatedly, strtoul allows a lot of unwanted stuff (spaces, +/- sign, thousand seperators), we really ought not use it. But that's for another time. Signed-off-by: Ran Benita <ran@unusedvar.com>
* compose: add a limit of 65535 sequencesRan Benita2021-03-303-10/+18
| | | | | | | | Fits in uint16_t, which enables some future optimizations. But also a good idea to have some limit. Not aware of any compose files which come close. Signed-off-by: Ran Benita <ran@unusedvar.com>
* utils: assert on streq for NULL pointersPeter Hutterer2021-03-301-0/+1
| | | | | | We have streq_null for that purpose Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: move an assert up to before the strlen() usePeter Hutterer2021-03-301-1/+2
| | | | | | | | ../../../test/keysym.c:80:24: warning: Null pointer passed to 1st parameter expecting 'nonnull' [core.NonNullParamChecker] (unsigned) strlen(expected)); Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* xkbcomp: remove useless assignmentPeter Hutterer2021-03-301-1/+1
| | | | | | | | | ../../../src/xkbcomp/compat.c:693:16: warning: Although the value stored to 'merge' is used in the enclosing expression, the value is never actually read from 'merge' [deadcode.DeadStores] si.merge = merge = (def->merge == MERGE_DEFAULT ? merge : def->merge); Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* xkbcomp: use memcpy over strncpy to avoid analyzer warningsPeter Hutterer2021-03-301-4/+5
| | | | | | | | The target buffer is 7 bytes long, null-termination is optional (as the comment already suggests). Coverity is unhappy about this though so let's use memset and memcpy instead. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* man: add missing pointer to xkbcli-compile-keymap(1)Ran Benita2021-03-291-0/+4
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* keysym: fast path for case sensitive xkb_keysym_from_nameRan Benita2021-03-283-52/+2621
| | | | | | | | | | | | | xkb_keysym_from_name() is called a lot in Compose file parsing. The lower case handling slows things down a lot (particularly given we can't use the optimized strcasecmp() due to locale issues). So add separate handling for the non-case-sensitive case which is used by Compose. To do this we need to add another version of the ks_tables table. This adds ~20kb to the shared library binary. We can probably do something better here but I think it's fine. Signed-off-by: Ran Benita <ran@unusedvar.com>
* keysym: inline find_sym functionRan Benita2021-03-281-56/+46
| | | | | | It's easier when everything is in one place. Signed-off-by: Ran Benita <ran@unusedvar.com>
* keysym: use a more descriptive argument nameRan Benita2021-03-281-11/+11
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* keysym: open-code bsearchRan Benita2021-03-281-34/+26
| | | | | | | We want to optimize things here which requires messing with the binary search some. Signed-off-by: Ran Benita <ran@unusedvar.com>
* interactive-evdev: fix missing initializationRan Benita2021-03-281-1/+1
| | | | | | Accidentally got lost in 6b65be4. Signed-off-by: Ran Benita <ran@unusedvar.com>
* interactive-evdev: switch from epoll(2) to poll(2)Ran Benita2021-03-284-29/+22
| | | | | | | | Turns out FreeBSD supports evdev, so this toll can work on it; however it does not support epoll, so switch to poll, which is portable. Reported-by: Evgeniy Khramtsov <evgeniy@khramtsov.org> Signed-off-by: Ran Benita <ran@unusedvar.com>
* x11: fix comparison of integer expressions of different signednessRan Benita2021-03-281-1/+1
| | | | | | | | src/x11/keymap.c:980:26: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare] 980 | for (size_t i = 0; i < length; i++) { | ^ Signed-off-by: Ran Benita <ran@unusedvar.com>
* xkbcomp: plug a potential memory leakPeter Hutterer2021-03-191-3/+8
| | | | | | | | | | | | | | libxkbcommon-1.0.3/src/xkbcomp/ast-build.c:526: leaked_storage: Variable "file" going out of scope leaks the storage it points to. Where we exit the loop early, we don't release the various allocated memory. Make this patch more obvious my moving the declaration for those into the loop as well, this way we know that they aren't used outside the loop anywhere. Found by coverity Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* registry: plug a potential memleak for invalid rules filesPeter Hutterer2021-03-191-0/+4
| | | | | | | If the name is missing in a configItem, we'd fail and leak the memory for description, brief and vendor. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: fix missing va_end in case of test failuresPeter Hutterer2021-03-191-6/+15
| | | | | | Found by coverity Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* bench: silence coverity complaint about a double freePeter Hutterer2021-03-191-1/+2
| | | | | | | | | | False positive because we rely on xkb_components_from_rules() to initalize this struct, but let's localize the variable anyway to shut coverity up. libxkbcommon-1.0.3/bench/rules.c:59:9: warning[-Wanalyzer-double-free]: double-free of kccgst.symbols Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Inline x11_atom_interner_adopt_atoms() into callersUli Schlachter2021-03-093-19/+8
| | | | Signed-off-by: Uli Schlachter <psychon@znc.in>
* Save another GetAtomName round tripUli Schlachter2021-03-093-76/+66
| | | | | | | | | | | | | | | Both get_atom_name() and the new atom interner required a round trip. Move get_atom_name() into the atom interner to save one more round trip. This brings xkb_x11_keymap_new_from_device() down to two round trips, which is the minimum possible number. (Also, I think the new code in keymap.c is more readable than the mess I previously created) With this last commit in the series, this definitely: Fixes: https://github.com/xkbcommon/libxkbcommon/pull/217 Signed-off-by: Uli Schlachter <psychon@znc.in>
* Also batch the XKB GetNames requestUli Schlachter2021-03-091-23/+24
| | | | | | This gets rid of another round trip. Signed-off-by: Uli Schlachter <psychon@znc.in>
* Also batch the XKB-GetMapMap requestUli Schlachter2021-03-091-15/+15
| | | | | | This gets rid of one more round trip. Signed-off-by: Uli Schlachter <psychon@znc.in>
* Remove three more round tripsUli Schlachter2021-03-091-18/+18
| | | | | | | | | | | | | | | There are a number of XKB requests needed to request all the information from the X11 server. So far, the code was sending one request and waiting for the reply. This commit starts batching the request so that we get multiple replies with one round trip. This removes three round trips. Only the simple requests are converted. get_map() and get_names() use some bitmasks that are needed for both the request and the reply. These will be dealt with separately. Signed-off-by: Uli Schlachter <psychon@znc.in>
* Save three more round trips in xkb_x11_keymap_new_from_device()Uli Schlachter2021-03-093-8/+39
| | | | | | | | Instead of asking for an atom name and waiting for the reply four times, this now sends four GetAtomName requests and waits for all the replies at once. Thus, this saves three round trips. Signed-off-by: Uli Schlachter <psychon@znc.in>
* xkb_x11_keymap_new_from_device: Less X11 round-tripsUli Schlachter2021-03-093-104/+157
| | | | | | | | | | | | | | | | | | On my system, calling xkb_x11_keymap_new_from_device() did 78 round trips to the X11 server, which seems excessive. This commit brings this number down to about 9 to 10 round trips. The existing functions adopt_atom() and adopt_atoms() guarantee that the atom was adopted by the time they return. Thus, each call to these functions must do a round-trip. However, none of the callers need this guarantee. This commit makes "atom adopting" asynchronous: Only some time later is the atom actually adopted. Until then, it is in some pending "limbo" state. This actually fixes a TODO in the comments. Fixes: https://github.com/xkbcommon/libxkbcommon/issues/216 Signed-off-by: Uli Schlachter <psychon@znc.in>
* Bump version to 1.1.0xkbcommon-1.1.0Ran Benita2021-02-272-1/+20
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* doc: add keymap-format-text-v1.md to the HTML documentationRan Benita2021-02-272-3/+10
| | | | | | It's incomplete but might be helpful for someone. Signed-off-by: Ran Benita <ran@unusedvar.com>
* doc: add note on variants in rule namesRan Benita2021-02-271-0/+3
| | | | | Fixes: https://github.com/xkbcommon/libxkbcommon/issues/208 Signed-off-by: Ran Benita <ran@unusedvar.com>
* Fix a few keysymtab entries to match their comment in xkbcommon-keysyms.hPierre Le Marre2021-02-271-3/+3
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* scripts: remove meson-junit-report.pyRan Benita2021-02-271-92/+0
| | | | | | Not used since ed5a0b4fede69b8e6dc4db53d97ea4ae0a73956d. Signed-off-by: Ran Benita <ran@unusedvar.com>
* meson.build: replace the remaining join_paths() with the nicer / syntaxPeter Hutterer2021-02-221-1/+1
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* test: add a keysym testerPeter Hutterer2021-02-222-5/+92
| | | | | | | | | | | A simple script that creates a new layout with the given keysym replacing TLDE. Then we compile a keymap and search for the keysym being assigned to TLDE and bail if that fails. The list of keysyms is manually maintained but we only need to add one or two to spot-check whenever the xorgproto is updated. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Fix documentation for XKB_CONFIG_EXTRA_PATHPeter Hutterer2021-02-221-2/+2
| | | | Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Update keysym definitions to latest xorgprotoPeter Hutterer2021-02-222-3593/+4258
| | | | | | As of xorgproto commit e5d8af9711516385f8346c9e077692b29c914478 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* scripts: update makeheader script for the _EVDEVK keysym definesPeter Hutterer2021-02-221-0/+11
| | | | | | | | | | | | | | | | | | As of xorgproto commit 5dbb5b76597f [1], the 0x10081XXX keycode range is defined for direct evdev kernel keycode mapping. For example, KEY_MACRO1 (0x290) is mapped to 0x10081290. The format of the #define lines for these keys is stable to allow for parsing: #define XF86XK_FooBar _EVDEVK(0x123) /* optional comment */ Update our script so we detect these new lines. Our keysym generation is a two-step process: makeheader and then makekeys. Replacing the key with its full value in the makeheader script means we don't have to update makekeys to handle the _EVDEVK macro and our header file is fully resolved. [1] https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/merge_requests/23 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* Update imported comments in xkbcommon-keysyms.hPeter Hutterer2021-02-221-3/+3
| | | | | | Matches xorgproto commits 39eb5974 and 09602b213. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>