mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-15 08:56:26 -05:00
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.
This commit is contained in:
parent
63df2bcbe6
commit
44a4792fd8
7 changed files with 69 additions and 68 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue