Commit graph

330 commits

Author SHA1 Message Date
Peter Hutterer
56b82c2b8f Add DeviceRegions to replace the pointer/touch ranges
This is required for supporting synergy/barrier and similar clients.
Replacing the touch and pointer range we now have server-defined
rectangular regions that specify the active zones for this device.

For example, a dual-monitor EIS server would create two touch devices
with one region each for the respective monitors - libei-generated
touches would thus fall on the right area of the monitor. Or just one
device with one region if the second screen should be inaccessible.

A relative device may have multiple regions since it can reach all
screens in the layout.

This leaks the screen layout to libei but that is necessary for the
functionality to work. A libei client may need to control devices
through absolute coordinates and it needs to know where screen
transitions from one to the next screen happen:

  +-----------++----------------+
  |           ||                |
  |          B||Q               |
  |           |+----------------+
  |           |
  |          A|P
  +-----------+

In the above example, position P is unreachable and a client that
controls input on both screens must know that it cannot transition from
A to P but it can transition from B to Q.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-23 15:06:01 +10:00
Peter Hutterer
12b04fdeb0 Add a DeviceAddedDone message to the protocol
Similar to wayland's done message, this signals the end of the device
configuration.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-23 14:26:38 +10:00
Peter Hutterer
0578a8cbb6 doc: fix some doxygen markup errors
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-23 14:25:56 +10:00
Peter Hutterer
088c328251 doc: change to doxygen-awesome
Much better looking than the previous style, even with no custom
configurations.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 14:20:18 +10:00
Peter Hutterer
926644e669 util: remove the need for a tmp argument in list_for_each_safe
With a bit of trickery, we can declare the tmp variable inside the for
loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:13:03 +10:00
Peter Hutterer
c0f9e40282 Pass the file/line/func information through to the ei/eis loggers
This is useful for debugging, let's pass it through and let the log
handler decide whether to use it or not.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:09:39 +10:00
Peter Hutterer
7f4c8b8247 util: pass the file/line/func information through to the logger
This is useful for debugging, let's pass it through and let the log
handler decide whether to use it or not.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:09:39 +10:00
Peter Hutterer
b527128c27 test: don't print the message type for debug
Make Warning, Info and Error stick out more this way

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:09:39 +10:00
Peter Hutterer
a228dee0d2 eis: include util-macros in the private header for _printf_
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:09:39 +10:00
Peter Hutterer
974df9b5ce util: add a list_nth_entry() macro
Returns the nth element for a given list. Note that unlike the other
macros, this takes a type, not a variable as first argument.

Signed-off-by:Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:09:39 +10:00
Peter Hutterer
036f9fe7ee util: comment the list interface
Copied from libinput commit de70661213a916065dedeefcd617736a9d48da40
with a few fixes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 13:06:11 +10:00
Peter Hutterer
2f2043f24f eis: remove some leftover if 0 code from the server devices
Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 11:30:13 +10:00
Peter Hutterer
ea8b9d3cb8 test: better debugging of event passing
Log when we're passing an event up to the test case, makes tracing
things easier.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 11:30:13 +10:00
Peter Hutterer
9449d66828 test: split the ei tests up into different files
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 12:01:05 +10:00
Peter Hutterer
c940c22376 test: rename the main test to eierpecken
Why not have a bit of fun here.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 11:20:30 +10:00
Peter Hutterer
cc78331bba eis: insert an unbind event if we had a bound seat
If our client binds to a seat and then disconnects, insert an unbind
event in the EIS queue to unwind correctly.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 11:20:30 +10:00
Peter Hutterer
358a528478 Add support for seat unbinding
This required a bit of cleanup with the eis device handling.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 11:20:18 +10:00
Peter Hutterer
3e66c87e81 ei: make the device refcounting a bit easier to follow
Once a device is removed, it is moved to the seat's devices_removed
list and the seat's ref is dropped - meaning the seat no longer keeps
the device alive. Once the caller's refcounts drop, the device can be
destroyed.

The device still keeps the seat alive though through a ref.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 11:02:54 +10:00
Peter Hutterer
426c92d59c eis: start the device IDs at 1
device IDs are combined with the seat ID, let's make sure the lower bits
are never 0 to be able to distinquish between a pure seat ID and a
device ID.

Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 11:02:54 +10:00
Peter Hutterer
2bb846696f Change to use server-created devices
This changes the protocol so that it is the EIS implementation that
creates devices within a seat.

A client now "binds" to a seat and the EIS implementation creates
devices matching the requested capabilities. A client can close a device
if it no longer wants those but otherwise everything (including pointer
ranges) is handled by the server.

This is one giant patch because changes at the protocol level cannot
easily be broken out into smaller patches. Some FIXMEs are left which
will be handled in follow-up patches, e.g. the keymap handling is
basically broken right now.

Fixes #7

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-21 11:02:54 +10:00
Peter Hutterer
a5049c4b93 util: add more useless structs to avoid semicolon issues
Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-20 16:30:42 +10:00
Peter Hutterer
11e3fc7709 util: indent the object.h code by tabs
Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-20 16:30:37 +10:00
Peter Hutterer
7e7a3e1b16 util: add _unused_ macro
Silences some compiler errors about unused static inlines.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-20 10:49:47 +10:00
Peter Hutterer
a78b0d3e26 Shut up two doxygen warnings about undocumented parameters
Signed-off-by:	Peter Hutterer <peter.hutterer@who-t.net>
2021-07-20 10:49:47 +10:00
Peter Hutterer
f0abe8f19a Include stddef.h for size_t
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-20 10:49:47 +10:00
David Redondo
27e7823029 Implement support for scroll events
The interfaces were declared on both client and server  side but not
implemented.

Signed-off-by: David Redondo <kde@david-redondo.de>
2021-07-16 08:40:07 +02:00
David Edmundson
ce755e4334 tools/demo-server: create a seat in uinput mode
The uinput path ended up diverged from the printf codepath and does not
create any seats and we can't process events.

Signed-off-by: David Edmundson <davidedmundson@kde.org>
2021-07-07 22:30:23 +01:00
Peter Hutterer
23696006f1 tools/demo-server: handle abs motion events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-11-04 12:48:24 +10:00
Peter Hutterer
c317de742b libei: immediately remove devices added for a removed seat
Once the SEAT_REMOVED event has been processed, adding new devices is
pointless. But we do promise a DEVICE_REMOVED event for any device added with
ei_device_add(), so let's immediately queue an event and mark the device as
dead.

Since the SEAT_REMOVED event may still be pending in the queue (i.e. not yet
read by the client), we need to prepend the event to the queue. Note that
client that immediately add a device when a device is removed will cause
an infinite loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-29 14:10:47 +10:00
Peter Hutterer
f068ddf2a8 libei: only log the state when it changed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-29 14:10:47 +10:00
Peter Hutterer
57fc23c67d libei: require ei_device_remove() for a never-added device
This simplifies the handling of devices that were never added a bit, including
handling the refs between seat and device. And for legitimate use-cases
there's no reason why a caller would create a device but never add it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-29 12:23:35 +10:00
Peter Hutterer
659de273e9 libei: skip logging if we don't have a log handler
Mostly useful for the unit tests, saves on setup.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-29 11:50:23 +10:00
Peter Hutterer
03e5a547f5 test: add a few more tests for disconnection behavior
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-29 11:28:29 +10:00
Peter Hutterer
eef9c51df3 libei: fix the device/seat ref handling once again
Previously we didn't always clean up properly, especially where unexpected
removals happened. So the new approach is:
- the device always has a ref to the seat, we must not remove the seat until
  even not-yet-added devices are released
- the seat has a ref to the device *after* it was added. this is a circular
  ref so we need to make sure the device is manually removed from the seat
  so we can actually reach a refcount 1

This is made slightly more complicated by us calling ei_disconnect() whenever
we fail to write on the fd. The result is re-entrant functions that we need to
protect against inadvertent changes. The best option here is probably to mark
the context as degraded and clean up once we finished whatever we were really
doing - that's a larger rework though.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-29 11:28:29 +10:00
Peter Hutterer
96109fb415 test: when dropping the ei context, also drop our seat ref
Otherwise we don't actually clean up everything, making the whole thing
pointless.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-28 15:41:29 +10:00
Peter Hutterer
11857968c6 test: handle dispatch helpers for NULL contexts
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-27 13:30:43 +10:00
Peter Hutterer
0558866f5b test: add a test to simulate the xdotool/xwayland behavior
xdotool sends the events and disconnects immediately, Xwayland queues up those
events until it has a seat but then also disconnects immediately. Let's
emulate this behavior so we can catch breakages before Xwayland sees them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-27 11:35:11 +10:00
Peter Hutterer
683ff5cca0 Fix double device removal
Removing a seat could cause two device remove events to happen. Fix this by
splitting the removal up into two bits: removed by server and removed by
client. Only once both bits are set, remove the device.

This needs to happen in libei and libeis.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-27 11:35:06 +10:00
Peter Hutterer
1db2af00c5 test: some better debugging of events
Add a debug marker to show any changes done during the final event processing,
and print the event name for wrong event types.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-26 14:35:57 +10:00
Peter Hutterer
3dafd9a362 libeis: better message debugging
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-26 13:54:47 +10:00
Peter Hutterer
ebe6261c89 README: mention seats in the high-level overview
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-26 12:02:45 +10:00
Peter Hutterer
f3a225c757 examples: update the examples for seats
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-26 08:53:33 +10:00
Peter Hutterer
0429ca2491 libei: print the device IDs as hex in the added/resumed/suspended debug logs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-23 14:25:53 +10:00
Peter Hutterer
54c06f8d1e libeis: add eis_client_get/set_user_data
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-22 14:05:09 +10:00
Peter Hutterer
51bec40aa5 tools/demo-server: split the keymap handling into two functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 11:36:44 +10:00
Peter Hutterer
08650b0268 tools/demo-server: set the server keymap in our local struct
Where the demo server is run with a --layout, set that in our local struct so
the printed messages use the correct keysyms.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 11:36:37 +10:00
Peter Hutterer
787a664b5a libeis: don't treat it as bug when the client doesn't send a keymap
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 11:29:55 +10:00
Peter Hutterer
ab386f3cdb util: add an _unref_ cleanup + declaration function
To cut down on the boilerplate, an unref-able struct variable can now be
declared as
   _unref_(type) *name = NULL;
which is the equivalent of
   _cleanup_(type_unrefp) struct type *name = NULL;

Let's see how that style ends up reading.

This means we can get rid of the custom _cleanup_foo_ functions everywhere, no
need for all the extra #defines etc. A somewhat special case is systemd which
defines the various unrefp functions for us in the headers, so we can use them
directly.

OBJECT_IMPLEMENT_UNREF now also creates the unrefp function for this object -
this of course conflicts where DECLARE_UNREF_CLEANUP_FUNC is in scope. Not a
problem so far, let's see how we go.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 11:17:16 +10:00
Peter Hutterer
2076057ba2 util: add a macro to create unref cleanup functions
Slightly less boilerplate than before.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 10:47:47 +10:00
Peter Hutterer
5e24b35ecb tools: use a cleanup func for the event in the demo client
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 10:47:47 +10:00