Commit graph

12 commits

Author SHA1 Message Date
Peter Hutterer
69dcea11b9 path: add libinput_path_add_device() and libinput_path_remove_device()
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>
2014-02-10 11:23:36 +10:00
Peter Hutterer
6764e7e19a path: modify backend to allow for more than one device
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>
2014-02-10 11:23:35 +10:00
Peter Hutterer
9d3fbabb5e path: add error handling for failing to create a seat
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-02-06 09:46:34 +10:00
Peter Hutterer
1901449871 Move opening and closing the device fd into evdev.c
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>
2014-02-06 09:16:43 +10:00
Peter Hutterer
b5f06f8329 path: fix inconsistent use of devnode vs input->path
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-31 15:00:17 +10:00
Peter Hutterer
184c95c147 path: print error when failing to open a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-31 14:57:18 +10:00
Peter Hutterer
5d7e0fbfec path: store the sysname, not the syspath, in the device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-31 14:57:18 +10:00
Jonas Ådahl
8264c3b60b evdev: Make evdev manage its seat reference
Before the seat reference would be decreased when a device was removed.
This could cause libinput_device_get_seat() to potentially return an
invalid pointer when a device was removed, its seat unreferenced and
destryoed.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-01-22 23:59:32 +01:00
Peter Hutterer
f5bc28b31a path: get ID_SEAT and WL_SEAT from udev for the device node
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-22 11:16:29 +10:00
Peter Hutterer
c29a8e8093 Split seats into having a physical and a logical name
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-17 18:17:45 +10:00
Peter Hutterer
5b5b6bca06 Drop seat events
seats are more a compositor concept than a concept of the input library. All
devices in a libinput context are associated with the seat given on creation
of the seat (maps to ID_SEAT in udev for the udev backend).

A logical seat may be assigned to a device (e.g. WL_SEAT) but this does not
necessarily map to the creation of the seat in the compositor.
Drop the seat events but keep seat objects around so that the caller can still
identify which seat a device belongs to.

If the libinput_seat_unref() in the udev backend destroys the seat, the device
list of that seat is invalid and we'd be accessing already freed bytes. To
avoid this, ref the seat before the device removal loop, then unref it once
we're done - that unref then may trigger the actual removal of the seat.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-17 18:17:11 +10:00
Peter Hutterer
069fc60b8b Add libinput_create_from_path
Hooking libinput up to udev isn't always possible, especially if libinput were
to be used in the X server which already has the udev handling built-in.
Add an option to create a context from a path.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-01-10 11:08:24 +10:00