Commit Graph

1865 Commits (fef179cfe7d8d72a0705202e9dcfd2196932f3ac)

Author SHA1 Message Date
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
Ran Benita fadfb13c42 xkbcomp/rules: support \r\n line endings
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 14:19:22 +02:00
Ran Benita d1e39c111e test/atom: use correct format specifier for size_t
From MSVC:

test\atom.c(98): note: consider using '%zu' in the format string
test\atom.c(98): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
test\atom.c(100): note: consider using '%zu' in the format string
test\atom.c(100): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
test\atom.c(114): note: consider using '%zu' in the format string
test\atom.c(114): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
test\atom.c(128): note: consider using '%zu' in the format string
test\atom.c(128): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
test\atom.c(130): note: consider using '%zu' in the format string
test\atom.c(130): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t'
test\atom.c(137): note: consider using '%zu' in the format string
test\atom.c(137): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 2 has type 'size_t'

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 14:13:52 +02:00
Ran Benita da4a90c13e Open files in binary mode
This turns off some misfeatures on Windows, and does nothing on POSIX.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 13:49:40 +02:00
Ran Benita fe417d841e test/common: avoid double // in path
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 13:40:38 +02:00
Ran Benita eb23982cab test/common: simplify test_get_path()
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28 13:39:33 +02:00
Ran Benita 521bb498ed xkbcomp: remove cast which triggers warning on gcc
Will need some other way to take care of the warning on MSVC.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 22:09:34 +02:00
Ran Benita fbd0e643d8 xkbcomp: make a couple of casts explicit to mark them as checked
This acknowledges some "possible loss of data cast" warnings from MSVC.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 21:55:14 +02:00
Ran Benita f967d46b65 test/context: use a more portable directory-exists check
MSVC doesn't have opendir/closedir.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 15:47:49 +02:00
Ran Benita 1849158afd xkbcomp/keywords: regenerate with newer gperf
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 15:20:25 +02:00
Ran Benita 823708b73e parser: fix format string for int64_t
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 15:20:25 +02:00
Ran Benita 670566f0d4 Only add GCC diagnostic pragmas when compiler is GCC compatible
Avoid "unknown pragma" warnings on other compilers.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 15:20:25 +02:00
Ran Benita 40bea8e9fa xkbcomp: fix wrong return type
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>
2019-12-27 15:04:40 +02:00
Ran Benita 6ca1a0c9f6 parser: use int64_t for all numbers
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>
2019-12-27 14:17:55 +02:00
Ran Benita c3ac58a941 scanner-utils: avoid possible implicit truncating of line/column
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>
2019-12-27 14:06:47 +02:00
Ran Benita 0fdd29bb7b utils: move macro defines to before they're used
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 13:55:24 +02:00
Ran Benita 64137a4ab5 utils: fix typo in strndup fallback
Fixup 93a1305 - we will have CI for this soon.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 13:52:51 +02:00
Adrian Perez de Castro d59ff39d22 meson.build: Take win_bison as a possible variant for Bison
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 13:21:34 +02:00
Ran Benita 40aab05e77 build: include config.h manually
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>
2019-12-27 13:09:11 +02:00
Adrian Perez de Castro bdff8ebe3c Provide a fallback implementation of [v]asprintf()
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.
2019-12-27 12:45:34 +02:00
Adrian Perez de Castro 93a13050d6 Provide a fallback implementation of strndup()
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]
2019-12-27 12:45:14 +02:00
Adrian Perez de Castro a8acc2ff5c Use built-in istr[n]cmp() instead of strcase[n]cmp()
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.
2019-12-27 12:36:39 +02:00
Ran Benita 34122f9f06 utils: use MIN/MAX instead of min/max
min/max symbols conflict on some systems (msvc), so just use the macros.

Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27 12:34:49 +02:00
Ran Benita ade131307c xkbcomp: downgrade "Symbol added to modifier map for multiple modifiers" log 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>
2019-12-27 12:26:35 +02:00