Commit graph

928 commits

Author SHA1 Message Date
Peter Hutterer
1175595acf tools: make the demo client send the correct discrete events
Multiples of 120 are needed
2023-06-01 15:12:07 +10:00
Peter Hutterer
cc053155a5 doc: change the doxygen oeffis group to liboeffis
This way the links are consistent with the libei/libeis groups.
2023-05-31 16:11:57 +10:00
Peter Hutterer
868a16df85 ei: ei_device_get_width/height need to be public APIs 2023-05-31 01:06:32 +00:00
Peter Hutterer
35ec414215 Remove unimplemented ei_device_get_keymap()
This is ei_device_keyboard_get_keymap() instead
2023-05-30 19:11:44 +10:00
Peter Hutterer
37e2bdebed CI: add a comment to the meson build helper
We now have an upstream for it so we can sync changes between projects.
2023-05-30 15:18:04 +10:00
Peter Hutterer
3ef22c8ed0 Log a bug if a client tries to send a discrete value 1
Discrete values are multiples of 120 and it's unlikely the device to be
emulated is *that* precise, so let's assume it's a bug and the client
wasn't aware of the 120-multiple requirement.
2023-05-30 11:14:57 +10:00
Peter Hutterer
3e908c03f4 log: remove trailing linebreaks from log messages
These are no longer needed or desired (see 37467881e6)
2023-05-29 17:54:20 +10:00
Peter Hutterer
1aedabe7c7 libeis: check incoming objects' version for correctness
If the server sends a protocol version higher than we support, fail.
2023-05-26 19:16:15 +10:00
Peter Hutterer
c99f4ffa2c libei: check incoming objects' version for correctness
If the server sends a protocol version higher than we support, fail.
2023-05-26 19:16:15 +10:00
Peter Hutterer
f081e8e79f proto: add a version argument to ei_connection.sync
This is the only request that creates a new object but doesn't specify
the version for that object, courtesy of copy/paste from the wayland
protocol. In libei/libeis this a bit was hidden away so it didn't get
noticed - but it was already buggy: libei would always hardcode to
version 1 but libeis would take whichever ei_callback version was agreed
upon during handshake. This version could be higher than 1.

This is a protocol break but we're still pre-1.0, there are very few
people that will be affected by this and it's better than having to
carry this bug around for years.

Fixes #35
2023-05-26 07:01:19 +00:00
Peter Hutterer
552f6dcbd0 ei-scanner: expose version_arg and version_arg_for
Points to the correspoding "version" argument, or points back to the
argument this version argument is for.
2023-05-26 16:56:13 +10:00
Ian Douglas Scott
1d8cd84c56 ei-scanner: Expose interface_arg, and also provide interface_arg_for
To make this practical to use in a template, we want relations in both
directions. And at least for consistency with other things, these fields
should contain the `Argument` instead of just its name string.

So we need to do this after are the arguments in the message have been
initially parsed. Adding these fields when parsing the request/event
close tag seems to work well enough.

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-05-26 16:55:47 +10:00
Peter Hutterer
00226da59e scanner: add tests for the extra data arguments
Fixed in !218, let's test this so we don't break it again.
2023-05-25 10:09:28 +10:00
Peter Hutterer
3a9eb2d8b6 scanner: rework the main() function into something easier to test
Rename to scanner() and take an argument vector that can be passed to
ArgumentParser.parse_args(). This makes testing the scanner's CLI a lot
easier.
2023-05-25 09:51:42 +10:00
Ian Douglas Scott
091948e9ef ei-scanner: Fix --jinja-extra-data-file, and make mypy check pass 2023-05-24 11:33:12 -07:00
Peter Hutterer
016072507e CI: add a build test for our minimum meson version
Since meson is installed from pip, we'll use the latest stable version
when we build an image. Add an extra job with the fixed minimum version
so we ensure we actually build with that version.
2023-05-24 08:16:43 +10:00
Peter Hutterer
a75828aee0 meson.build: drop requirements back to 0.56
The bump to 0.60 was required for 2a2c4cdd but is no longer required
after 27ff400b.
2023-05-24 08:16:29 +10:00
Peter Hutterer
93fd69cdf3 libei 1.0.0rc2 2023-05-23 14:50:33 +10:00
Peter Hutterer
708aed6402 Export the event names through helper functions
Approximately every user of libei(s) will want something like this for
easier debugging, converting the numeric event type into something that
can be printed into the debug logs.

Let's provide this here so this doesn't need to be duplicated.
2023-05-22 02:39:08 +00:00
Peter Hutterer
ca06927371 test: add some tests for the ei-scanner itself
This is a bit convoluted because ei-scanner is named like that, so it
cannot be imported as python module. The solution for that is to
copy/rename it with meson to the builddir and run pytest in that. This
also allows us to set the path to the protocol XML file while we're at
it so we can use it as a fixture.

Actual tests are minimal for now, can be extended over time.
2023-05-22 10:54:28 +10:00
Peter Hutterer
f142f802f4 scanner: add the Interface.plainname property
Returns "connection" for the "ei_connection" interface, i.e. the
interface stripped of any component prefix.
2023-05-22 00:24:39 +00:00
Jan Beich
708d0f57e8 util: silence warnings when memfd_create is missing
src/util-memfile.c:55:1: warning: unused function 'memfile_create' [-Wunused-function]
OBJECT_IMPLEMENT_CREATE(memfile);
^
src/util-object.h:164:16: note: expanded from macro 'OBJECT_IMPLEMENT_CREATE'
struct type_ * type_##_create(struct object *parent) { \
               ^
<scratch space>:133:1: note: expanded from here
memfile_create
^

test/test-ei-device.c:37:1: warning: unused function 'memfile_unrefp' [-Wunused-function]
DEFINE_TRIVIAL_CLEANUP_FUNC(struct memfile *, memfile_unref);
^
src/util-mem.h:56:21: note: expanded from macro 'DEFINE_TRIVIAL_CLEANUP_FUNC'
        static inline void _func##p(_type *_p) {                \
                           ^
<scratch space>:159:1: note: expanded from here
memfile_unrefp
^
2023-05-21 09:04:16 +00:00
Jan Beich
e27f039b32 brei: silence warnings on 32-bit architectures
src/brei-shared.c:231:16: warning: comparison of integers of different signs: 'int' and 'uint32_t' (aka 'unsigned int') [-Wsign-compare]
                        if (end - p < len32) {
                            ~~~~~~~ ^ ~~~~~
src/brei-shared.c:233:76: warning: format specifies type 'long' but the argument has type 'int' [-Wformat]
                                                       "Invalid string length %u, only %li bytes remaining", s->len, (end - p) * 4);
                                                                                       ~~~                           ^~~~~~~~~~~~~
                                                                                       %i

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-05-21 09:04:16 +00:00
Ian Douglas Scott
cf932d1efb tools: Consistently refer to $XDG_RUNTIME_DIR
In one place, `$XDG_RUNTIME` was referenced. Which is wrong since the
variable is called `$XDG_RUNTIME_DIR`. The other uses referred to
`XDG_RUNTIME`, which could be taken as a shorthand, but it's clearer to
just use the name of the variable.
2023-05-20 02:28:48 +00:00
Ian Douglas Scott
349ec5b790 doc/protcol: Change references of ei_device.keymap to ei_keyboard 2023-05-20 02:28:48 +00:00
Peter Hutterer
3aed761f3d eis: don't log a warning for a disconnecting client that's disconnected
A client that does ei_disconnect() sends out the 'disconnect' protocol
message before closing the fd. On the libeis side, this will cause a
Connection error when reading past that message. Logging that as error
looks bad when this is normal behavior.

The 'disconnect' protocol message changes the client into the
REQUEST_DISCONNECT state. If we get a transport error when the client is
in that state, don't log an error - the client wanted to be disconnected
anyway and even if it's a legitimate socket failure there isn't anything
we can do about it anyway.
2023-05-19 05:10:58 +00:00
Peter Hutterer
e21f14d69f Log a connection error before disconnecting
This makes the debug logs easier to read - previously we'd get an error
and disconnect. That causes unwinding of the state internally
(including lots of debug messages) and then eventually the actual error
that caused the disconnect.

Reshuffle this, so we see the "Connection error" first before all the
unwiding of the state, making it easier to spot what caused the actual
error.
2023-05-19 05:10:58 +00:00
Peter Hutterer
82e8f20fff CI: clone the upstream repo for the abidiff job
The forked repo may not have the latest tags. And we only need to run
this on MRs, no point ABI-diffing on every push.
2023-05-19 14:49:17 +10:00
Peter Hutterer
6970a5153a pre-commit: add a hook to generate the CI templates
Simple local hook that is skipped if ci-fairy isn't installed locally.
2023-05-19 14:49:17 +10:00
Peter Hutterer
4184e37442 CI: add an abidiff job 2023-05-18 23:00:43 +00:00
Jan Beich
27ff400bc2 meson: allow selecting sd-bus library via option
Roughly based on https://github.com/swaywm/sway/commit/fdbe98512a71

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-05-18 22:55:18 +00:00
Peter Hutterer
fe2abeda9d eis: drop declaration for eis_client_has_capability()
The implementation of this was removed in 408a3a94
2023-05-18 22:03:27 +00:00
Peter Hutterer
73662468cf CI: bump to use F38 2023-05-18 07:26:54 +00:00
Jan Beich
cc046f1f67 util: avoid /proc on BSDs (but keep for tests)
/proc is removed on OpenBSD, deprecated on FreeBSD or may not contain
Linux-style nodes.

Not mounted:

  test_cmdline_as_str                  [ ERROR ]
  Error: src/util-strings.c:483: assertion failed: fd >= 0 (-1 >= 0)

Mounted but only has /proc/curproc instead of /proc/self:

  test_cmdline_as_str                  [ ERROR ]
  Error: child killed by signal 11
2023-05-18 05:11:55 +00:00
Jan Beich
c7517b2737 liboeffis: expand sd_bus_close_unref for basu compatibility
ld: error: undefined symbol: sd_bus_close_unref
>>> referenced by liboeffis.c:116 (src/liboeffis.c:116)
>>>               liboeffis.c.o:(oeffis_destroy) in archive src/liboeffis.a

See also https://github.com/systemd/systemd/commit/bd62b7448623
2023-05-18 05:11:55 +00:00
Jan Beich
2a2c4cdd49 meson: depend on elogind or basu if systemd is missing
systemd isn't portable to non-Linux. However, sd-bus API was extracted
into a standalone library that works on BSDs.
2023-05-18 04:25:44 +00:00
Jan Beich
35e7ad9717 meson: depend on epoll-shim for BSDs
src/util-sources.c:29:10: fatal error: 'sys/epoll.h' file not found
 #include <sys/epoll.h>
          ^~~~~~~~~~~~~

ld: error: undefined symbol: epoll_ctl
>>> referenced by util-sources.c:76 (src/util-sources.c:76)
>>>               libutil.a.p/util-sources.c.o:(source_remove) in archive src/libutil.a
>>> referenced by util-sources.c:200 (src/util-sources.c:200)
>>>               libutil.a.p/util-sources.c.o:(sink_add_source) in archive src/libutil.a

ld: error: undefined symbol: epoll_create1
>>> referenced by util-sources.c:152 (src/util-sources.c:152)
>>>               libutil.a.p/util-sources.c.o:(sink_new) in archive src/libutil.a

ld: error: undefined symbol: epoll_wait
>>> referenced by util-sources.c:169 (src/util-sources.c:169)
>>>               libutil.a.p/util-sources.c.o:(sink_dispatch) in archive src/libutil.a
2023-05-18 04:15:36 +00:00
Jan Beich
53482faa57 meson: depend on math library for BSDs
ld: error: undefined symbol: __isnormal
>>> referenced by util-strings.h:243 (src/util-strings.h:243)
>>>               test/unit-tests-utils.p/.._src_util-strings.c.o:(xatod)
2023-05-18 04:15:36 +00:00
Peter Hutterer
3b8ce3dca1 Drop a few unused unref functions
Fixes 'warning: unused function 'ei_device_unrefp' [-Wunused-function]'
and friends.
2023-05-18 14:03:26 +10:00
Peter Hutterer
7015fa6ad0 brei: move the object_id_t typedefs to the brei-proto.h header
It's not the perfect place but here it does the least harm and it fixes
the noisy compiler warnings:
'warning: redefinition of typedef 'object_id_t' is a C11 feature [-Wtypedef-redefinition]'

Fixes #31
2023-05-18 14:03:26 +10:00
Peter Hutterer
92b002a013 CI: move the pip package list into the config.yml file as well 2023-05-18 12:07:19 +10:00
Peter Hutterer
ade03d5245 CI: install meson and ninja from pip
Let's keep testing against the most recent stable meson/ninja releases.
2023-05-18 12:05:59 +10:00
Peter Hutterer
df268d618a libei 1.0.0rc1 2023-05-17 12:28:12 +10:00
Peter Hutterer
5215be1079 README: fix the paragraph talking about the protocol 2023-05-17 12:28:12 +10:00
Peter Hutterer
9d2568e55b proto: fix a typo 2023-05-16 15:47:49 +10:00
Peter Hutterer
e0a6c75cb4 protocol: widen the callback_data arg for ping/sync to 64bit
The only invocations we have right now of these callbacks ignore the
argument or force it to zero. But in the future we may have an interface
that requires a callback and that interface may need to store a
timestamp or object ID in this argument - so let's make sure we have
enough space for that.
2023-05-16 15:09:47 +10:00
Peter Hutterer
32c03fab35 proto: document the callback-data for pingpong/callback better 2023-05-16 15:06:49 +10:00
Peter Hutterer
cdab45a9f4 ei: drop unused ei_insert_device_removed_event()
Unused since 2bb846696f "Change to use server-created devices"
2023-05-16 11:47:01 +10:00
Peter Hutterer
3e47f544c2 ei: drop ei_seat_bind_capability() and the unbind equivalent
This function is almost always wrong, very few clients will want to bind
to a single capability. Having this function means clients will use it to
bind caps one-by-one, causing the EIS implementation to create (an later
destroy) devices with capabilities that are about to be bound again anyway.
Better to have an API that encourages clients to bind all at once.

EIS implementation could avoid this by using a pingpong roundtrip in
response to a bind call, but removing this API is likely going to have
the same utility.
2023-05-10 12:25:40 +10:00
Peter Hutterer
44de97d649 test: switch to use ei_seat_bind_capabilities()
Better than one-by-one where we bind multiple capabilities. And
ei_seat_bind_capability() is about to be removed so let's switch all
of them.
2023-05-10 12:21:40 +10:00