libinput is supposed to take a close callback in its interface
to allow you to call out to a privileged API to close FDs. But
the FD that libinput passes you is bogus, because
libinput_remove_source closes the FD on which it's passed. This
is really bad, as the libinput_source really doesn't own the FD
which it's passed, so it shouldn't be trying to close() it.
Only one out of the four users of libinput_remove_source actually
wants their FD closed, so move the close() call there.
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Instead of having one touch events representing different types of touch
events by providing a touch type, have one separate event type per touch
type. This means the LIBINPUT_EVENT_TYPE_TOUCH is replaced with
LIBINPUT_EVENT_TYPE_TOUCH_DOWN, LIBINPUT_EVENT_TYPE_TOUCH_MOTION,
LIBINPUT_EVENT_TYPE_TOUCH_UP and LIBINPUT_EVENT_TYPE_TOUCH_CANCEL.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Since a Wayland compositor have to represent all touch devices of a seat
as one virtual device, lets make that easier by also providing seat wide
slots with touch events.
Seat wide slots may be accessed using
libinput_event_touch_get_seat_slot().
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Avoids erroneous timestamps when the system time is reset. This used to a be a
problem with the X.Org synaptics driver where taps, scrolling and a couple of
other things would potentially lock up.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This gives us the ability to handle SYN_DROPPED transparently to the caller.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
libevdev wraps the various peculiarities of the evdev kernel API into a
type-safe API. It also buffers the device so checking for specific features at
a later time is easier than re-issuing the ioctls. Plus, it gives us almost
free support for SYN_DROPPED events (in the following patch).
This patch switches all the bit checks over to libevdev and leaves the event
processing as-is. Makes it easier to review.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
A caller may have a reference to the device after closing it, make sure that
ref doesn't have a dangling fd so future attempts of reading from/writing to
the device fail.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
X and Y are li_fixed_t, which is 24.8 fixed point real number.
li_fixed_t max is thus ~8388607.
On a touchscreen with a range of 32767 values (like a 3M sensor), and
mapped on monitor with a resolution of 1920x1080, we currently have:
(x - li_fixed_from_int(device->abs.min_x)) * width == 62912640
which is 7 times bigger than li_fixed_t max.
Force a cast to uint64_t to keep the precision of the sensor.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Add a test case and test device that checks if the scale transform can
handle high resolution devices and output monitor resolutions.
The test case is created in a way that it will fail if the coordinate
transform expression will overflow if only 32 bit integer data
containers are used.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The previous log handler wasn't actually hooked up to anything. Add a public
API for the log handler with priority filtering, defaulting to priority
'error' and stderr as output stream.
And to keep the diff down and convenience up, provide a few simple wrappers
for logging. The generic is log_msg(), but let's use log_info, log_error, etc.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
It is unclear what "current" means as events are asynchronous, and
since a slot is associated with a touch event rather than a device,
change the description to reflect this.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
With this patch, a user can keep a reference to a libinput_seat
instance, which will cause the seat to never be unlinked from the
libinput context nor destroyed.
Previously, a when the last device of a seat was removed, the seat was
unlinked and if a new device was discovered with a previously empty seat
a new seat instance would always be created, meaning two potential seat
instances with identical physical and logical seat name pairs.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
If we don't have capabilities we can deal with, return a different
error so the backends can handle it separately (they already do).
Signe-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Creates an empty context that is not hooked up to a device. Callers can then
add and remove devices to this context using libinput_path_add_device() and
libinput_path_remove_device().
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This allows multiple devices to share a single libinput context. The new
function returns the newly added device immediately. Unlike the udev seat
where devices may or may not be added - over the lifetime of the seat - a
path-based backend knows immediately if device exists or doesn't exist.
Returning the device is required by callers that have the event processing
separate from adding devices - by the time we have the DEVICE_ADDED event in
the queue we may have other events to process first. And the DEVICE_ADDED
event won't easily link to the path we gave it anyway, so it's hard to figure
out which DEVICE_ADDED event corresponds to the new device.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The previous path backend created a libinput context attached to a single
device. This is insufficient when we need to use cross-device functionality.
One example of this cross-device functionality include disabling a touchpad
while the trackstick is in use (Lenovo T440 and related models).
This patch merely adds the infrastructure to support multiple devices for a
path backend. Follow-up patches add the function calls to add and remove
devices. This is needed by Xorg input drivers that still make use of the
server's device hotplug mechanisms but want to otherwise use libinput.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This reverts commit e8c20c7241.
Ooops, bad rebase. This accesses the device after it was already destroyed
which is not the intent of the patch.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
If we don't have capabilities we can deal with, return a different error so
the backends can handle it separately (they already do).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
evdev_device_remove() already calls close(device->fd). Move the
close_restricted call there to avoid one privileged call in the backend and
one in the device. And move the open_restricted() into the evdev device too to
reduce the duplicated code in the two backends.
Update to one of the tests: since we'd now fail getting the device node from
the invalid /tmp path, the open_func_count is 0.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Since the device min/max x/y coordinates are inclusive, to get the
width/height one need to add one to (min x/y - max x/y).
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
The event represent pointer motions on a screen, so this information is
unnecessary. It could also be confused for meaning the provided
coordinate's direction being device specific.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Instead of automatically transforming absolute coordinates of touch and
pointer events to screen coordinates, the user now uses the corresponding
transform helper function. This means the coordinates returned by
libinput_event_pointer_get_absolute_x(),
libinput_event_pointer_get_absolute_y(), libinput_touch_get_x() and
libinput_touch_get_y() has changed from being in output screen coordinate
space to being in device specific coordinate space.
For example, where one before would call libinput_event_touch_get_x(event),
one now calls libinput_event_touch_get_x_transformed(event, output_width).
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Simply prints the various events to make it easier to check what's coming out
of libinput. Works for --udev (the default) or for --device /dev/input/event0.
Example output:
event7 DEVICE_ADDED seat0 default
event8 DEVICE_ADDED seat0 default
event4 POINTER_BUTTON +1.35s 272 pressed
event5 POINTER_MOTION +2.31s -3.00/ 2.00
Time is displayed relative to the starting time.
Note: statically linked for easier debugging, but we don't distribute it
(yet) anyway.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Currently this means start with "event" and don't contain /.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
This was a detail of the original version of the commit "evdev: Remove
EVDEV_TOUCH and with it evdev_device->caps" that got lost during porting.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>