Commit Graph

2225 Commits (b5a140832bee358bc9e2ec702cf68258f4424f4e)

Author SHA1 Message Date
Peter Hutterer 127f8c976d utils: assert on streq for NULL pointers
We have streq_null for that purpose

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 01:37:55 +03:00
Peter Hutterer d172652753 test: move an assert up to before the strlen() use
../../../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>
2021-03-30 01:37:55 +03:00
Peter Hutterer fa86433e7c xkbcomp: remove useless assignment
../../../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>
2021-03-30 01:37:55 +03:00
Peter Hutterer 20f7f80c23 xkbcomp: use memcpy over strncpy to avoid analyzer warnings
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>
2021-03-30 01:34:33 +03:00
Ran Benita cda2eaf1f5 man: add missing pointer to xkbcli-compile-keymap(1)
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-03-29 20:59:45 +03:00
Ran Benita 7d84809fdc keysym: fast path for case sensitive xkb_keysym_from_name
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>
2021-03-28 16:11:36 +03:00
Ran Benita 3b506497bf keysym: inline find_sym function
It's easier when everything is in one place.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-03-28 16:11:36 +03:00
Ran Benita 2d87ab08f3 keysym: use a more descriptive argument name
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-03-28 16:11:36 +03:00
Ran Benita a717549eb2 keysym: open-code bsearch
We want to optimize things here which requires messing with the binary
search some.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-03-28 16:11:36 +03:00
Ran Benita c14910a0de interactive-evdev: fix missing initialization
Accidentally got lost in 6b65be4.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-03-28 16:11:36 +03:00
Ran Benita 6b65be4c4e interactive-evdev: switch from epoll(2) to poll(2)
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>
2021-03-28 14:39:03 +03:00
Ran Benita 62b5b4a170 x11: fix comparison of integer expressions of different signedness
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>
2021-03-28 13:02:27 +03:00
Peter Hutterer 95e2907978 xkbcomp: plug a potential memory leak
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>
2021-03-19 23:44:30 +02:00
Peter Hutterer 01aa222257 registry: plug a potential memleak for invalid rules files
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>
2021-03-19 23:44:30 +02:00
Peter Hutterer 694b8f7127 test: fix missing va_end in case of test failures
Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-19 23:44:30 +02:00
Peter Hutterer 7a205e25ac bench: silence coverity complaint about a double free
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>
2021-03-19 23:44:30 +02:00
Uli Schlachter 21c864ccbf Inline x11_atom_interner_adopt_atoms() into callers
Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-03-09 11:00:13 +02:00
Uli Schlachter c033970163 Save another GetAtomName round trip
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>
2021-03-09 11:00:13 +02:00
Uli Schlachter c8efc3d67d Also batch the XKB GetNames request
This gets rid of another round trip.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-03-09 11:00:13 +02:00
Uli Schlachter 599064cf28 Also batch the XKB-GetMapMap request
This gets rid of one more round trip.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-03-09 11:00:13 +02:00
Uli Schlachter 1b3a1c277a Remove three more round trips
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>
2021-03-09 11:00:13 +02:00
Uli Schlachter b9707c1db0 Save three more round trips in xkb_x11_keymap_new_from_device()
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>
2021-03-09 11:00:13 +02:00
Uli Schlachter 40c00b4721 xkb_x11_keymap_new_from_device: Less X11 round-trips
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>
2021-03-09 11:00:13 +02:00
Ran Benita 82a5bdc43c Bump version to 1.1.0
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-02-27 22:48:35 +02:00
Ran Benita 83e3a53ddc doc: add keymap-format-text-v1.md to the HTML documentation
It's incomplete but might be helpful for someone.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-02-27 22:38:21 +02:00
Ran Benita afc5370c86 doc: add note on variants in rule names
Fixes: https://github.com/xkbcommon/libxkbcommon/issues/208
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-02-27 22:13:17 +02:00
Pierre Le Marre 30ce6c04f9 Fix a few keysymtab entries to match their comment in xkbcommon-keysyms.h
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-02-27 22:06:42 +02:00
Ran Benita 2dd391b66e scripts: remove meson-junit-report.py
Not used since ed5a0b4fed.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-02-27 21:38:02 +02:00
Peter Hutterer d1ba81c4dd meson.build: replace the remaining join_paths() with the nicer / syntax
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-22 13:43:16 +02:00
Peter Hutterer 0abd430e85 test: add a keysym tester
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>
2021-02-22 13:43:16 +02:00
Peter Hutterer b4802b0642 Fix documentation for XKB_CONFIG_EXTRA_PATH
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-22 13:43:16 +02:00
Peter Hutterer 0bfc71e7b5 Update keysym definitions to latest xorgproto
As of xorgproto commit e5d8af9711516385f8346c9e077692b29c914478

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-22 13:43:16 +02:00
Peter Hutterer 3852106a8e scripts: update makeheader script for the _EVDEVK keysym defines
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>
2021-02-22 13:43:16 +02:00
Peter Hutterer 5c1f4f0da0 Update imported comments in xkbcommon-keysyms.h
Matches xorgproto commits 39eb5974 and 09602b213.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-22 13:43:16 +02:00
Peter Hutterer 069777f47f test: fix interactive evdev test invocation
rmlvos is the parent list which then fails during a list join because, well,
it's a list of lists.

Fixes #206

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-23 18:57:23 +02:00
Peter Hutterer d5e3695ea2 test: fill in srcdir/builddir when not set in the environment
Makes this test easier to run from the commandline. Where either of top_srcdir
or top_builddir isn't set, fill them in from the CWD or fail otherwise.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-23 18:57:23 +02:00
Ran Benita 44df69c928 doc/keymap: some slight editing
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-12-27 09:49:20 +02:00
Simon Zeni 7420521ff4
doc/keymap: add documentation for xkb_symbols (#205) 2020-12-27 09:48:39 +02:00
Ran Benita c60b77ea51 Bump version to 1.0.3
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-23 20:30:13 +02:00
Ran Benita fbf087ea94 keymap-dump: follow xkbcomp in printing affect=both in pointer actions
It is equivalent to nothing but good to match up.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-23 20:03:17 +02:00
Ran Benita ac6cd20c55 x11: fix type level names missing
When reading the keymap, the level names would get discarded.
Regressed in 26453b8473.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-23 18:49:49 +02:00
Ran Benita 95f8ff8355 test/data: update host.xkb to match keymap-dump style
This is needed for fixing the x11comp test.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-23 18:35:27 +02:00
Ran Benita 4aed3c6811 x11/keymap: fix case with no actions
Possible regression in f41e609bbe (not
confirmed yet).

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-23 18:24:52 +02:00
Ran Benita 13e6543ed4 Bump version to 1.0.2
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-20 21:02:44 +02:00
Ran Benita 1bd3b3c7cb x11: cache X11 atoms
On every keymap notify event, the keymap should be refreshed, which
fetches the required X11 atoms. A big keymap might have a few hundred of
atoms.

A profile by a user has shown this *might* be slow when some intensive
amount of keymap activity is occurring. It might also be slow on a
remote X server.

While I'm not really sure this is the actual bottleneck, caching the
atoms is easy enough and only needs a couple kb of memory, so do that.

On the added bench-x11:

Before: retrieved 2500 keymaps from X in 11.233237s
After : retrieved 2500 keymaps from X in 1.592339s

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-20 13:04:21 +02:00
Ran Benita f41e609bbe x11: eliminate slow divisions
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-20 12:50:50 +02:00
Ran Benita 9caa4128c2 build: combine test & bench internal deps
No need to duplicate this really.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-19 16:19:56 +02:00
Ran Benita d9a22f29c0 ci: fix windows CI failure due to add-path deprecation
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-19 01:31:09 +02:00
Peter Hutterer 6268ba1c77 test: catch unrecognized keysyms in the xkeyboard-config test
Prompted by
https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/merge_requests/127

We run the keymap tool with --verbose which will print the messages from the
compiler to the log file as well. And then we can search for the warning
regarding an unrecognized keysym and fail our test based on that.
2020-10-20 11:02:03 +10:00
Peter Hutterer afdc9ceee7 xkbcomp: where a keysym cannot be resolved, set it to NoSymbol
Where resolve_keysym fails we warn but use the otherwise uninitialized variable
as our keysym. That later ends up in the keymap as random garbage hex value.

Simplest test case, set this in the 'us' keymap:
    key <TLDE>               {      [        xyz ] };

And without this patch we get random garbage:
./build/xkbcli-compile-keymap --layout us | grep TLDE:
    key <TLDE>               {      [      0x018a5cf0 ] };

With this patch, we now get NoSymbol:
./build/xkbcli-compile-keymap --layout us | grep TLDE:
    key <TLDE>               {      [        NoSymbol ] };
2020-10-20 09:23:50 +10:00