Commit Graph

2038 Commits (097a0ca7d688621c2346eb19c2b1b37746cf1273)

Author SHA1 Message Date
Peter Hutterer 9b1b0c5743 Add a snprintf_safe() helper function
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>
2020-07-06 15:15:20 +10:00
Peter Hutterer d075c3e697 Factor the access check for paths out
Easier to re-use without having to duplicate ifdefs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-06 15:15:20 +10:00
Peter Hutterer 43b9d09248 test: fix the xkeyboard-config test for the prefixed tool name
Regression introduced in 362130debb

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-01 08:19:40 +10:00
Ran Benita 878cc7a574 tools: don't depend on src/utils.h
The idea is to make the tools/demos as standalone as possible so that
they may serve as examples as well.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-06-28 09:50:47 +03:00
Peter Hutterer 8b8a464576 tools: allow stdin for compiling keymaps
This connects two tools to be useful together:
  xkbcommon-rmlvo-to-kccgst | xkbcommon-print-compiled-keymap  -
which will result in the full keymap generated by the former tool.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 0ecd55223d tools: print the kccgst format in a usable syntax
Might as well spit that out in the format that e.g. xkbcomp understands.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 314b6486b3 test: drop some now-obsolete functions
These were moved to tools/tools-common.c and now that all tools are switched
over, they're no longer needed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 362130debb meson.build: prefix all tools with xkbcommon-
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 3adbe54eac tools: move the remaining tools from test to here
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer f525f9f040 test: disentangle interactive-wayland from the test headers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 1326d5add4 test: untangle interactive-x11 from the test headers
Use the new tools headers and create a custom internal lib for the x11 tool.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer c09bf36306 test: untangle interactive-evdev from the test headers
Move (sometimes duplicate) the required bits into new shared files
tools-common.(c|h) that are compiled into the internal tools library. Rename the
test_foo() functions to tools_foo() and in one case just copy the code of the
keymap compile function to the tool.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 2eb5d2c81d test: simplify error handling in interactive-evdev
Passing -errno around and having separate labels depending on failure types is
superfluous here. All the unref calls can handle NULL and nothing cares about
errno once we're out of the immediate scope. So let's simplify this and deal
with 0 and 1 only.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 6c629a10cf Use a custom internal library for the tools
This is currently identical to the internal test library, but it's a start to
disentangle the two.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer ec2bbe599c Move the various tools to a tools/ directory
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 725a31986d test: how-to-type: prefer local headers over system ones
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 928771ede0 test: untangle rmlvo-to-kccgst from the test headers
Using test helpers to init the context gives it fairly specific behavior; unless
the user sets the right environment variables and/or calls it from the right
PWD, it may or may not include the test data.

Let's drop this behavior, make it a default tool to compile a keymap. If there
is a specific need to modify the include paths, we can add this later.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer e5d4056e2f test: untangle print-compiled-keymap from the test headers
Commit 16c84cdd81 removed the getopt handling for
RMLVO arguments, so now this tool only takes a keymap file and compiles it.

Using test helpers to init the context gives it fairly specific behavior; unless
the user sets the right environment variables and/or calls it from the right
PWD, it may or may not include the test data.

Let's drop this behavior, make it a default tool to compile a keymap. If there
is a specific need to modify the include paths, we can add this later.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer 7d1aefddad test: simplify an exit path
The unref() functions take NULL as argument, so we don't need different labels
for every possible exit path.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-25 10:32:08 +10:00
Peter Hutterer bdbf1a190d Remove the gitignore file
This contained three groups entries:
- autotools stuff which no longer needed
- entries to ignore built artifacts, no longer needed with meson as everyting is
  in the builddir
- special files like cscope.out, etc. These should be handled by a user in their
  global gitignore file since they're fairly specific to a user's setup.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-22 14:14:30 +03:00
Peter Hutterer 4e544e2792 doc: correct the include path list
XKB_CONFIG_ROOT (if defined) replaces the built-in system directories.

Fixes 5fb2c6769b

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-16 11:26:49 +03:00
Peter Hutterer 5fb2c6769b doc: add documentation for user configuration
Most of this is currently hidden in the commit message for ca033a29d2, let's
make it a bit more public so we have a link to point users to.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-15 07:32:10 +03:00
Peter Hutterer a26578742c doc: add the rules-format file (as markdown)
Useful to have this as part of the documentation. The rendering isn't great but
at least not any worse than pure text. Markdown escapes % so explaining our use
of %S and %H would require a double % - not idea. Let's just wrap it as a code
block and done.

Includes two typo fixes too, yay.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-15 07:32:10 +03:00
Peter Hutterer fef179cfe7 Add an editorconfig file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-02 06:46:21 +10:00
Ran Benita 892cfef834 keysyms: add XKB_KEY_XF86FullScreen
Updated using ./scripts/update-keysyms using latest xorgproto.

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/147
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-05-20 20:42:02 +03:00
Ran Benita 860cfc039f keymap: don't forget about fallback mappings in 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>
2020-04-18 22:23:06 +03:00
Jon Turney 908e014f01 Fix building X11 tests on PE targets
Link libxkbcommon_x11_internal with libxkbcommon_test_internal, rather
than libxkbcommon.

This avoids some tests linking with both libxkbcommon_test_internal and
libxkbcommon, which causes duplicate symbol problems on PE targets (e.g.
Cygwin) (as all the symbols from libxkbcommon are pulled in at link
time, which clash with libxkbcommon_test_internal)
2020-04-18 22:15:51 +03:00
Ran Benita ed5a0b4fed ci: remove azure pipelines build
Broken, replaced with github actions.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-04-18 21:55:28 +03:00
Ran Benita 8dfece0cbb ci: add github actions build
We currently use Azure Pipelines. But it became out of date. Also it
requires a different account and setup than github account itself.

The configuration here is probably not very good and is less featureful
than the Azure one but it's what I managed.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-04-18 21:55:28 +03:00
Nils 0f1cae0cc4
test: use flag instead of hardcoded value in examples 2020-03-25 10:43:41 +02:00
Ran Benita 8a1709a411 test/how-to-type: some code fixes/improvements
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-03-21 12:56:13 +02:00
Ran Benita 188a1c79f1 test: add "how to type" demo program
The program takes a unicode codepoint and an RMLVO and prints out all
key + modifier combinations that would result in that codepoint.

The program was written to exercise the new
xkb_keymap_key_get_mods_for_level() function. It's handy and can be
extended in several ways, but enough for now.

Example:

    $ ./build/how-to-type -l us,il,ru 0x41 | column -ts $'\t'
    keysym: A (0x41)
    KEYCODE  KEY NAME  LAYOUT#  LAYOUT NAME   LEVEL#  MODIFIERS
    38       AC01      1        English (US)  2       [ Shift ]
    38       AC01      1        English (US)  2       [ Lock ]
    38       AC01      2        Hebrew        2       [ Shift ]
    38       AC01      2        Hebrew        2       [ Lock ]

    $ ./build/how-to-type -l de -v neo 0x3b6 | column -ts $'\t'
    keysym: Greek_zeta (0x7e6)
    KEYCODE  KEY NAME  LAYOUT#  LAYOUT NAME     LEVEL#  MODIFIERS
    56       AB05      1        German (Neo 2)  4       [ Shift Mod5 ]
    56       AB05      1        German (Neo 2)  4       [ Shift Mod2 Mod3 Mod5 ]
    56       AB05      1        German (Neo 2)  4       [ Shift Lock Mod5 ]
    56       AB05      1        German (Neo 2)  4       [ Lock Mod2 Mod3 Mod5 ]

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-03-20 19:40:14 +02:00
Ran Benita 90e5aa8bc5 doc: add missing `@since` tags
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-03-20 19:40:14 +02:00
Jaroslaw Kubik d92a248c48 API to query modifier set required to type a keysym
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).
2020-03-20 19:20:36 +02:00
Jaroslaw Kubik 0345aba082 Support translation Unicode codepoints to keysyms
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().
2020-02-24 09:54:09 +02:00
Ran Benita 1b23a650ab build: fix build with byacc
We apparently broke byacc support in the switch to meson.

byacc only supports short option names. And to make things fun, bison
only supports long option for `--defines`.

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/133
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-02-18 14:12:20 +02:00
Ran Benita c90703265f doc: must -> should
Using an out-of-range is not an error, just useless.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-02-16 13:32:09 +02:00
Ran Benita e3c3420a71 Bump version to 0.10.0
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-01-18 23:08:45 +02:00
Ran Benita 517464eb7a doc/rules-format.txt: document include support
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-01-18 23:06:58 +02:00
Ran Benita 335ebcadd4 docs: add missing reference to $XDG_CONFIG_HOME
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-01-18 22:59:58 +02:00
Adrian Perez de Castro d2f2e6fd5c CI: Add build instructions for Windows
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 16:12:15 +02:00
Adrian Perez de Castro 9e3045c7f5 MSVC: Provide an implementation of gettimeofday() 2019-12-28 16:12:15 +02:00
Adrian Perez de Castro f1186acfd4 MSVC: Provide implementations of [un]setenv()
Reference:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-s-wputenv-s
2019-12-28 16:12:15 +02:00
Adrian Perez de Castro abb2f9d978 MSVC: Provide implementations of test_{dis,en}able_stdin_echo
This provides implementations of the test_enable_stdin_echo and
test_disable_stdin_echo which do not require <termios.h>, which is
not available on Windows.
2019-12-28 16:12:15 +02:00
Adrian Perez de Castro 5354dee2f7 MSVC: Use <io.h> as an alternative for <unistd.h>
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>
2019-12-28 16:12:15 +02:00
Adrian Perez de Castro f09ae987bf build: Skip building some tests on MSVC for now
This is a stopgap measure to quickly get tests building with MSVC for
now, at some point the tests could be rewritten to avoid using getopt()
and mkdtemp() or to ship an implementation.
2019-12-28 16:12:15 +02:00
Adrian Perez de Castro 578aeac6b2 build: add some defines for MSVC to allow it to be unixy
[ran: combined some commits]
2019-12-28 16:12:15 +02:00
Ran Benita 92a7aba6ad ci: use consistent python for all jobs
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 16:05:32 +02:00
Ran Benita faac4ba7de test/data: ensure files are checked out with LF, not CRLF
The tests stringcomp and buffercomp do binary comparison on some files;
if the files are changed to CRLF on checkout, the tests fail.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 15:59:47 +02:00
Adrian Perez de Castro b30bf21c82 CI: some tweaks
[ran: extracted generic bits from Windows commit.]

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 15:32:30 +02:00