Commit graph

198 commits

Author SHA1 Message Date
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
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
Peter Hutterer
4adf483195 test: add the new caps to the bind-all-caps test
And bind them all at once, might as well
2023-05-10 12:21:04 +10:00
Peter Hutterer
fafc30d4cc meson.build: change the test builds to be a feature
This way we get to use 'auto' feature which will enable the tests
as dependencies are available. Right now, the basic tests don't have any
dependencies beyond what libei needs, only the pytests have extra
requirements that are handled in the 'auto' processing.
2023-05-10 12:10:40 +10:00
Peter Hutterer
bd1dd67892 test: fix the oeffis pytest
Since the soname was added, the liboeffis.so file no longer exists in
the build directory - it is created on install.

Not sure how this passed the CI pytest run but it certainly fails
locally.
2023-05-10 12:10:40 +10:00
Peter Hutterer
408a3a9462 eis: drop the vestiges of client restrictions
Leftover from 479bda259a (and possibly
others). This dates back to when a client could have restrictions
configured on the same fd. This is now all out-of-band (portals!) so the
compositor knows what the client is allowed to set up anyway.

No need for this (read-only) API here.
2023-05-08 13:38:40 +10:00
Peter Hutterer
e6954b76d3 eis: change the API to match the protocol interfaces closer
Same as the corresponding ei change a few commits ago, this one does all
the EIS renaming in the same manner.

As with the libei changes, an EIS implementation must now handle the
EIS_DEVICE_CAP_BUTTON and EI_DEVICE_CAP_SCROLL capabilities. In
virtually all cases, clients will likely expect that a device with the
pointer or absolute pointer capabilities will also have button and
scroll capabilities.
2023-05-05 14:04:17 +10:00
Peter Hutterer
da37da1308 ei: change the API to match the protocol interfaces closer
Now that the protocol interfaces are more fine-grained, let's match this
with the C API too.

This is just a rename of things so that in general
ei_pointer_*foo now becomes ei_foo*.

A few notable renames for better readability here:
- ei_device_scroll_delta (because scroll_scroll is awkward)
- ei_event_scroll_get_dx/dy and
  ei_event_scroll_get_discrete_dx/dy to indicate the delta-ness

Beyond that, clients must ensure to check/bind to the new
EI_DEVICE_CAP_BUTTON and EI_DEVICE_CAP_SCROLL capabilities to be able
to send button or scroll events.

Note that this API now allows for an EIS implementation to send a device
that only has a button or a scroll cap. Or a pointer cap without
buttons, etc. It's up to the clients how to handle such devices
(probably: ignore them).
2023-05-05 14:02:33 +10:00
Peter Hutterer
a902d5dbd8 protocol: replace the capabilities enum with an interface list
Previously we had ei_seat.capabilities and ei_device.capabilities,
both referring to the same enum. The seat caps were used to bind,
the device caps were used to announce capabilities.

The device caps were already mostly superfluous as the information
they carried was implicitly available by the set of interfaces
the device announced - if the device has a keyboard interface
it must also have the keyboard capability.

So let's drop the separate enum and make the capabilities
the set of supported interfaces. In the device we can drop the
event directly and just send the interface list. In the seat
we have a capability event that sends each *possible* interface
with a custom-assigned mask. The client can then use that mask
to bind to the capability as before.

For example:
   <- ei_seat.capability(0x1, "ei_pointer")
   <- ei_seat.capability(0x4, "ei_keyboard")
   <- ei_seat.capability(0x8, "ei_touchscreen")
   <- ei_seat.done()
   -> ei_seat.bind(0x4 | 0x8)  # bind to keyboard and touchscreen
   <- ei_seat.device()
   -> ei_device.interface("ei_keyboard")
   -> ei_device.interface("ei_touchscreen")
   <- ei_device.done()

In the generated bindings we simply use the interface index
to generate the masks, but the protocol at least states that
the mask may not be constant.

Because the button/scroll interfaces are not exposed by the C API, some
of the handling is a bit awkward since we need to use both depending
whether we have pointer/pointer_absolute selected.

Fixes #28

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-05-02 05:53:25 +00:00
Peter Hutterer
bf88b34918 Split the ei_pointer interface up into its components
Split the ei_pointer protocol interface into ei_pointer,
ei_pointer_absolute, ei_scroll and ei_button.

This gets rid of the slightly awkward pointer vs pointer absolute
handling. Those were two different capabilities but tied to the same
interface.

Plus it paves the way for devices that are keyboards with scroll
buttons, etc.
2023-05-02 05:53:25 +00:00
Peter Hutterer
6215eecfbd test: fix a debug log typo 2023-04-27 15:22:07 +10:00
Peter Hutterer
24680aef2e test: use an enum iterator to loop through the interface names 2023-04-06 13:57:20 +10:00
Peter Hutterer
5aad9fd777 scanner: add the protocol name so we can compile some #defines
The protocol name on an interface is a fixed string that is part of
the ABI since it's used in a few messages (e.g.
ei_handshake.interface_version). To avoid typos, let's expose that
string in the scanner and #define it in the generated sources.
2023-04-06 13:57:20 +10:00
Peter Hutterer
99b36ba652 test: add a test for pointer vs abs pointer receiving 2023-04-06 13:57:20 +10:00
Peter Hutterer
7f7880d953 test: add test for receiving the device interfaces 2023-04-06 13:57:20 +10:00
Peter Hutterer
5b1b5aec1a proto: replace pointer/keyboard/touchscreen with a generic "interface" event
Since these events are merely notifications of a single object, we can make
this more generic. This allows us to introduce future capabilities without
having to bump the seat.
2023-04-06 13:57:18 +10:00
Peter Hutterer
4b77664dc1 test: if we fail to load liboeffis.so, skip the rest of the pytests
This gives us a nicer behavior when (semi-intentionally) running pytest
in the source directory.
2023-04-06 12:04:51 +10:00
Peter Hutterer
6179c91580 test: fix the exception check for the missing eiproto module
When running pytest from the source directory we get a
ModuleNotFoundError, not an ImportError.
2023-04-06 12:04:35 +10:00
Peter Hutterer
0aa8bab9c0 test: drop the default timeouts to 2
There's no need to wait any longer.
2023-04-05 14:22:31 +10:00
Salman Malik
a438e46e18 config: Make memfd_create optional
`memfd_create` doesn't seem to be supported on
all platforms (e.g. ubuntu 18 has trouble with it).
Even though, I was able to substitute `memfd_create`
with a direct system call, I was not able to get
the `MFD_CLOXEC` flag (from fcntl.h) working cleanly
(there were redefinitions/conflicts for other
structures when trying to use <linux/*> headers).
Making it optional for time being till we have
figured out how to make it work broadly.
2023-03-28 11:24:06 +00:00
Peter Hutterer
74ed569fe0 test: skip the oeffis tests if we don't have dbusmock 0.28.5 2023-03-19 07:56:09 +00:00
Peter Hutterer
a95c9e1799 meson: drop version requirement to 0.56 so we can build on Bullseye
Looks like the only more recent meson feature we use is for
'exclude_suites' in the valgrind test setup. We can just skip that.
2023-03-19 07:56:09 +00:00
Peter Hutterer
8954d96227 Remove empty trailing newlines from all files 2023-03-13 08:52:08 +10:00
Peter Hutterer
30aab5179e Merge branch 'main' into wip/drop-protobuf 2023-03-07 12:55:18 +10:00
Peter Hutterer
367fa6384f test: fix the LD_LIBRARY_PATH to liboeffis
Make this dependent on liboeffis directly instead of hardcoding where it
should be.
2023-03-07 11:54:10 +10:00
Peter Hutterer
25e36eb24e meson: move the "build this?" checks into the subdirs
Let's decide on what to build in the doc/ and test/ directory rather
than in the main file.
2023-03-07 11:10:06 +10:00
Peter Hutterer
3c589f1b20 test: log all function calls to interfaces
Makes debugging easier to see exactly who's being called.
2023-03-03 11:27:01 +10:00
Peter Hutterer
59542a1ba0 test: group 4 bytes at a time in our hexlify function
Our protocol is groups of 4s, so make it easier to find individual items
in the hexdump.
2023-03-03 11:27:01 +10:00
Peter Hutterer
9700a47473 test: run pytest with xdist where available
A lot of the protocol tests have enforced timeouts because we need to
wait for the server to do something (or not). Running the protocol tests
with xdist means we can run those in parallel, which on my local box
roughly halves the time required to run all protocol tests.

Of course, this is all terrible. The only way to tell pytest to use
xdist is with `pytest -n <jobcount>`. But -n is only available if xdist
is installed. Dynamically adding commandline options is supposed to
be possible with `pytest_load_initial_conftests` in conftest.py, but
that doesn't actually work unless we're configuring a setuptool plugin.
Which we don't. What would work is `pytest_cmdline_preparse` but that
has been deprecated.

So we work around this by having meson check if xdist is available and
append `-n auto` for us.

In the CI let's be nice and only use the FDI_CI_CONCURRENT number of
jobs rather than hogging everything available. And, continuation from
"all is terrible": pytest complains if you have a hook that's unknown.
So if xdist is not available, you must not have the hook in conftest.py.
Which means we have to do it within an import + ImportError clause.

But yay, now we're saving literally seconds!
2023-03-03 11:27:01 +10:00
Peter Hutterer
a806968ec5 test: up the timeout for dispatch
10ms isn't enough, esp. when running under valgrind
2023-03-03 11:27:01 +10:00
Peter Hutterer
037e092b62 test: throw an exception if sock.connect fails
We don't want to drop the error here, we need to see why something
failed.
2023-03-03 11:27:01 +10:00
Peter Hutterer
9b390f5703 eis: don't send a disconnected event when the client requests disconnect
As the protocol spec says, EIS should treat this as already disconnected
and not touch the connection.

This fixes a memleak if a client connects and immediately disconnects -
when EIS processes the EIS_EVENT_CLIENT_CONNECT it may set up a bunch of
things like seats (the eis-demo-server does this). Then, later, when
the EIS_EVENTE_CLIENT_DISCONNECT is processed, it calls
eis_client_disconnect() but we were already in the disconnected state
and the seats would not get released.
2023-03-03 11:27:01 +10:00
Peter Hutterer
1b34bc6f7c test: distinguish better between stderr/stdout of the subprocess 2023-03-03 11:27:01 +10:00
Peter Hutterer
1a64b4963d Check incoming ids for validity
In libei we just check the range is correct.
In libeis we also check that the client is monotonically increasing the
id.
2023-03-03 11:27:01 +10:00
Peter Hutterer
086f96a702 proto: split up message length and opcode again
Now that we have 64 bit integers on the wire and 64 bit object IDs,
we're already different to the Wayland protocol. So we might as well get
the full length and split message length and opcode again to make header
parsing and composing simpler.

This effectively reverts commit bf45a7182cb2f4c13f11e141fc846244d3ac6212.
2023-03-03 11:27:01 +10:00
Peter Hutterer
ba51f434a6 proto: switch object ids to 64 bits 2023-03-03 11:27:01 +10:00
Peter Hutterer
2e1babbb84 test: simplify results handling in the python tests
No point appending the message header components to the results when we
just ignore them later anyway.
2023-03-03 11:27:01 +10:00
Peter Hutterer
c832ce3ddc protocol: split the handshake version negotiation from the other interfaces
Previously, we'd send one interface_version event for "ei_handshake"
immediately but all others after the client requests handshake.finish.
This was too confusing to document and not clear how it would work, so
let's make this simpler by splitting it up.

There is now a handshake_version event from the server, sent immediately
on connection that denotes the maximum version number for the interface.
And a handshake_version request from the client which must be the first
one by the client.
2023-03-03 11:27:01 +10:00
Peter Hutterer
35f5fa102c proto: rename ei_connection_setup to ei_handshake
This is a better name for the initial handshake and easier to
distinguish from the ei_connection this way too.

Suggested by Jonas Ådahl.
2023-03-03 11:27:01 +10:00
Peter Hutterer
f9446e8c02 test: strip all trailing zeroes from the protocol strings
This code worked because the only string we compared against was
"ei_connection_setup" which is 19 actual bytes.
2023-03-03 11:27:01 +10:00
Peter Hutterer
2aaf7acdfc test: fix a ruff warning - f-string without placeholder 2023-03-03 11:27:01 +10:00
Peter Hutterer
705c5d79ac test: remove unused python import 2023-03-03 11:27:01 +10:00
Peter Hutterer
47467bfe0e proto: rename connection_setup.done to .finish
Avoids ambiguity with the .done events from e.g. the seat or the device.
2023-03-03 11:27:01 +10:00
Peter Hutterer
0897722493 proto: drop the seat caps and cross-reference device caps instead 2023-03-03 11:27:01 +10:00
Jonas Ådahl
03c0ab73dd protocol: Add support for 64 bit integers on the wire
This is useful for e.g. not having to split timestamps.
2023-03-03 11:27:01 +10:00
Peter Hutterer
3fa396c012 test: add a framework for doing protocol tests directly
This tests the protocol layer which is hard to test using libei/libeis.
Similar to the generated C bindings we compile a eiproto.py file that is
then used in the test to talk protocol directly to the eis-demo-server
that we start up.

By sending the specific messages and checking things happen as we expect
on the socket we can verify that the EIS implementation is correct (and
robust enough).

In theory this could also be used to test some other binary with an EIS
implementation and the scaffolding is there to set LIBEI_TEST_SERVER to
that binary. Wether this works is untested though...
2023-03-03 11:27:01 +10:00
Peter Hutterer
273eda39ca Move the C proto templates to the src directory
These are very specific to libei/libeis, so let's not leave them
somewhere where they look like official bindings or something.
2023-03-03 11:21:26 +10:00
Peter Hutterer
b02b4f0901 Drop protobuf in favour of a custom protocol
This protocol is wayland-like though it uses a slightly different
message format. The XML file uses the same structure, except for the
"fixed" type which is "float" here.

The scanner uses a jinja template to generate source and header files
for ei and eis which are now used instead of the protobuf-generated
objects. Note that the scanner is a minimal working version, some
features like enum value checks are not yet implemented.

Unlike wayland we do not need to generate the libwayland-like library,
we only need the wire protocol parser - some shortcuts can thus be taken.

To keep the changes simple, the protocol currently is a flat protocol
with only one interface and all messages copied over from the previous
ei.proto file. In future commits, this will be moved to the respective
interfaces instead.
2023-03-03 11:20:42 +10:00
Peter Hutterer
e93ad6925c test: set the minimum bits for our test devices
size is required for phys devices and in the future libei will reject
devices with no useful capabilities.
2023-02-20 15:43:22 +10:00