Commit graph

149 commits

Author SHA1 Message Date
Peter Hutterer
d55da9466c meson.build: apply consistent indentation
Mostly whitespace changes, the non-whitespace ones are adding trailing
commas on last arguments and moving the closing ) into a separate line
for multiline function calls.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/364>
2025-11-06 10:56:01 +10:00
Hongfei Shang
3f48d11958 tools: fix print for touch up in demo client
Signed-off-by: Hongfei Shang <shanghongfei@kylinos.cn>
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/363>
2025-11-05 11:31:38 +08:00
Jason Gerecke
acff519ac3 tools: Support EIS_EVENT_DEVICE_READY in eis-demo-server
We move the calls to resume and start emulation of new devices into a
handler that gets called only once a device is ready. We also set the
EIS_FLAG_DEVICE_READY flag to inform libeis that we want to process
these ready events.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/346>
2025-10-17 13:38:47 +10:00
Peter Hutterer
851f935fe1 tools: print missing event types in the demo client
Instead of aborting, print something useful

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/332>
2025-05-19 11:34:54 +00:00
Peter Hutterer
2556ad38c6 tools: handle EI_EVENT_SYNC in the demo client
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/332>
2025-05-19 11:34:54 +00:00
Peter Hutterer
564f14a739 ei: add EI_EVENT_SYNC as opaque event to correctly schedule callbacks
See the corresponding eis commit for details.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
73e0e8d339 eis: add EI_EVENT_SYNC as opaque event to correctly schedule callbacks
This event is required to fix an issue with the current
ei_callback.done handling in libeis: previously we would imediately send
the ei_callback.done upon receiving ei_connection.sync from the client.
This results in incorrect behavior as we may have events in the queue
(and/or pending a frame) that the EIS implementation hasn't seen yet.
For example a client sending:
- ei_pointer.motion
- ei_connection.sync
- ei_device.frame
- ei_connection.sync

Will queue a motion + frame event on the EIS side during eis_dispatch()
but immediately receive done events for both sync requests.

This could be handled purely internally by keeping the sync event in the
queue but hidden to the caller - and automatically calling done when
it's that events turn, i.e. something like:

```
  struct eis_event *eis_get_event(struct eis) {
      struct eis_event *e = first_event(eis);
      if (e == EIS_EVENT_SYNC) {
           eis_callback_send_done(e);
           eis_event_unref(e);
           e = next_event(eis);
      }
      return e;
  }
```

but that opens us up to a set of potential bugs detailed in
https://gitlab.freedesktop.org/libinput/libei/-/issues/71#note_2694603

So let's go the easy route by having a new event type that does nothing
other than eis_event_unref() in the EIS implementation. This way we can
queue the event and have everything behave in-order and as expected.

Closes #71

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
e40796402b eis: add eis_ping() and the matching EIS_EVENT_PONG
Identical to "ei: add ei_ping() and the matching EI_EVENT_PONG" but for
libeis.

This wraps around ei_connection.ping to allow a C API user to add
synchronization points.

Closes #69

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
a278c7b371 ei: add ei_ping() and the matching EI_EVENT_PONG
This wraps around ei_connection.sync to allow a C API user to add
synchronization points.

Closes #69

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/316>
2024-12-18 04:30:01 +00:00
Peter Hutterer
3c88c0d3b2 tools/demo-server: note that aborting on unknown events is bad
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/322>
2024-12-17 15:59:02 +10:00
Peter Hutterer
2acf42db9c tools/debug-events: add missing linebreaks to the modifier event
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/320>
2024-12-09 12:41:24 +10:00
Peter Hutterer
247b6acd3c meson.build: allow disabling libei and libeis
This is primarily a development feature because it makes it easier to
develop a new feature for just one library without having to worry
about build errors in the other library (e.g. when new protocol parts
are added).

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/310>
2024-12-02 00:23:14 +00:00
Peter Hutterer
11aa10393b tool: allow for touchscreen-only seat in the demo server
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/312>
2024-11-29 12:27:48 +10:00
Peter Hutterer
1cf06d0af6 tools: fix colorprint in the demo server
This ended up as multiple print calls, better to compile the lot into a
single print message so its output can be collected correctly by pytest.

Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/312>
2024-11-29 12:27:48 +10:00
David Redondo
cf4ab5e73f Allow passing a fd to ei-demo-client
Like in ei-debug-events
2024-08-08 09:55:43 +10:00
David Redondo
ebde54f3b3 ei-demo-client: Remove obsolote portal option 2024-08-08 09:54:13 +10:00
Peter Hutterer
3e2e43e352 ei-demo-client: use xkb_keymap_new_from_buffer()
This is the more correct approach since we get a sized buffer from the
server and people may use this as reference code in their implementation.
Technically we cannot expect a true zero-terminated string from EIS.

Unfortunately this means we need to work around
libxkbcommon#307 to strip trailing zeroes from the buffer if any exist.
2024-07-29 14:54:31 +10:00
Peter Hutterer
a924888f0f ei-demo-client: use mmap to read the keymap
Closes #55
2024-07-29 14:53:35 +10:00
David Redondo
93efd3d14e eis-demo-server: Send a sensible discrete scroll value
So it can be a good example for people and doesn't log about
server bugs.
2024-03-05 22:47:05 +00:00
Peter Hutterer
2df570b203 tools: add an --iterations argument to ei-demo-client
Limits the number of poll() iterations before triggering a shutdown.
This allows us to use this tool for shutdown testing too - previously
it would just get killed and never performed a proper unwind.
2023-10-24 18:22:48 +10:00
Peter Hutterer
fd2999ffdb tools: add a --interval option to the demo server and client
Makes testing a few things easier.
2023-10-11 00:49:25 +00:00
Peter Hutterer
d9d4630567 tools/debug-events: print the region mapping id
This changes the region print format from a string to a dict
2023-09-01 12:18:20 +10:00
Peter Hutterer
c179b3dac1 tools: fix an indentation issue 2023-09-01 12:18:20 +10:00
Peter Hutterer
ac16ba77ff tools: start ei-debug-events for the fd we get from the oeffis demo tool
Once we get the fd, fork off ei-debug-events for that fd so we can debug
what the EIS implementation actually sends us.
2023-09-01 12:06:38 +10:00
Peter Hutterer
76652350cc Add a mapping_id to the regions
This allows a caller to match up a region with other data, e.g. in the
remote desktop case the same mapping_id can be assigned to the pipewire
stream that represents that output.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-08-30 09:18:26 +10:00
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
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
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
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
a890ce96bb tools: bind to the new capabilities in ei-debug-events 2023-05-10 12:21:04 +10:00
Peter Hutterer
a7f9712d83 tools: make the button/scroll caps available on demo-server seats 2023-05-08 14:08:32 +10:00
Peter Hutterer
1fc58e3a90 tools: ei-demo-client should bind all caps at once
Binding single capabilities is allowed but our device handling expects
the devices to be "complete". So if we bind to pointer only, the demo
server creates a pointer-only device and then fails at sending buttons.
2023-05-08 14:08:32 +10:00
Peter Hutterer
d01a39ef82 tools: ei-demo-client needs to bind to the new button/scroll caps 2023-05-08 13:49:31 +10:00
Peter Hutterer
3e39dabeac tools/demo-server: check if we have a touch before sending one
If the client was disconnected, the returned touch is NULL. Check for
that instead of blindly assuming we can send the touch.
2023-05-08 13:47:06 +10:00
Peter Hutterer
2a178f416f tools/demo-server: only print now if we actually have events
And move it to the start of the loop so we print the current timestamp
followed by processing the incoming events (if any). These events thus
should have timestamps less than now.
2023-05-08 13:47:06 +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
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
30aab5179e Merge branch 'main' into wip/drop-protobuf 2023-03-07 12:55:18 +10:00
Peter Hutterer
7810be8a80 meson: split into separate meson.build files for src/tools 2023-03-07 11:10:06 +10:00
Peter Hutterer
44295ab044 tools: add touch support to the ei-demo-client 2023-03-06 16:25:04 +10:00
Peter Hutterer
46bef9fe86 tools: add touchscreen support to the eis-demo-server 2023-03-06 16:11:55 +10:00
Peter Hutterer
8c2f51fcff tools: fix a debug message in the demo client 2023-03-06 16:11:53 +10:00
Jonas Ådahl
e4f23f69fc demos: Print timestamp 2023-03-03 11:27:01 +10:00
Peter Hutterer
c5ebd345fd tools: copy the default log handler to the eis demo server
The default log handler logs to stderr, but we want stdout here to have
it intermixed with our real log messages (easier to debug this way).
Would probably be better to have this somewhere shared but for now this
will do.
2023-03-03 11:16:48 +10:00
Peter Hutterer
1925218e15 tools: whitespace fix in the demo server 2023-02-13 13:24:37 +10:00
Peter Hutterer
92f92bc3a5 tools: cleanup our clients in the eis demo server
Where we're interrupted before a disconnect event from the client, we
would leave the demo client hanging. This upsets valgrind.
2023-02-13 13:24:37 +10:00
Peter Hutterer
129eabcd29 tools: add a comment to the demo server
Might save some other poor soul having to debug this ...
2023-02-13 13:24:37 +10:00
Peter Hutterer
ff9830c122 Add a sequence number to START_EMULATING
This makes it easier to correlate a particular input transaction
(whether there are events or not) with out-of-band information like the
planned portal InputCapture::Activated signal's "activation-id".
2023-02-09 11:48:29 +10:00
Peter Hutterer
a5cc87c837 Purge the properties from the protocol
The primary use-case for these properties in libei itself was to send
some fixed information (pid, cmdline and conection type). In the portal
case, these can be obtained out-of-band via the portal. In the
non-portal case these can be obtained from the socket itself (fetch pid,
look up /proc/pid/cmdline) which is just as reliable as trusting
whatever libei sends.

The only other use-case for the properties was the activation id in the
InputCapture::Activated portal signal. This can be achieved with a
serial in the START_EMULATING event.
2023-02-09 11:48:29 +10:00