aboutsummaryrefslogtreecommitdiff
path: root/backend/libinput
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-11-06 10:16:07 +0100
committerSimon Ser <contact@emersion.fr>2020-11-19 22:47:49 +0100
commit44a4792fd80acfeb15e2cf88304f283855689fd0 (patch)
tree5236060ec1e8a226476378f8c9c4ad4795ca250f /backend/libinput
parent63df2bcbe656b394b0bd152ab69147194dd74815 (diff)
backend/session: operate on wlr_device
Instead of operating on FDs in {open,close}_device, operate on wlr_devices. This avoids the device lookup in wlr_session and allows callers to have access to wlr_device fields. For now, we use it to remove wlr_session_signal_add and replace it with a more idiomatic wlr_session.events.change field. In the future, other events will be added.
Diffstat (limited to 'backend/libinput')
-rw-r--r--backend/libinput/backend.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c
index 12f76bbf..7037084d 100644
--- a/backend/libinput/backend.c
+++ b/backend/libinput/backend.c
@@ -17,12 +17,27 @@ static struct wlr_libinput_backend *get_libinput_backend_from_backend(
static int libinput_open_restricted(const char *path,
int flags, void *_backend) {
struct wlr_libinput_backend *backend = _backend;
- return wlr_session_open_file(backend->session, path);
+ struct wlr_device *dev = wlr_session_open_file(backend->session, path);
+ if (dev == NULL) {
+ return -1;
+ }
+ return dev->fd;
}
static void libinput_close_restricted(int fd, void *_backend) {
struct wlr_libinput_backend *backend = _backend;
- wlr_session_close_file(backend->session, fd);
+
+ struct wlr_device *dev;
+ bool found = false;
+ wl_list_for_each(dev, &backend->session->devices, link) {
+ if (dev->fd == fd) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ wlr_session_close_file(backend->session, dev);
+ }
}
static const struct libinput_interface libinput_impl = {