backends: Allow opening /sys/ files on MetaLauncher
libinput may want to access those for fetching LED status, as those are requested readonly, just forward the request to plain open(). https://bugzilla.gnome.org/show_bug.cgi?id=778472
This commit is contained in:
parent
ead62f1901
commit
2d18b18fe5
@ -58,6 +58,7 @@ struct _MetaLauncher
|
|||||||
Login1Session *session_proxy;
|
Login1Session *session_proxy;
|
||||||
Login1Seat *seat_proxy;
|
Login1Seat *seat_proxy;
|
||||||
|
|
||||||
|
GHashTable *sysfs_fds;
|
||||||
gboolean session_active;
|
gboolean session_active;
|
||||||
|
|
||||||
int kms_fd;
|
int kms_fd;
|
||||||
@ -220,6 +221,15 @@ on_evdev_device_open (const char *path,
|
|||||||
int fd;
|
int fd;
|
||||||
int major, minor;
|
int major, minor;
|
||||||
|
|
||||||
|
/* Allow readonly access to sysfs */
|
||||||
|
if (g_str_has_prefix (path, "/sys/"))
|
||||||
|
{
|
||||||
|
fd = open (path, flags);
|
||||||
|
if (fd >= 0)
|
||||||
|
g_hash_table_add (self->sysfs_fds, GINT_TO_POINTER (fd));
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
if (!get_device_info_from_path (path, &major, &minor))
|
if (!get_device_info_from_path (path, &major, &minor))
|
||||||
{
|
{
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
@ -243,6 +253,14 @@ on_evdev_device_close (int fd,
|
|||||||
int major, minor;
|
int major, minor;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (g_hash_table_lookup (self->sysfs_fds, GINT_TO_POINTER (fd)))
|
||||||
|
{
|
||||||
|
/* /sys/ paths just need close() here */
|
||||||
|
g_hash_table_remove (self->sysfs_fds, GINT_TO_POINTER (fd));
|
||||||
|
close (fd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!get_device_info_from_fd (fd, &major, &minor))
|
if (!get_device_info_from_fd (fd, &major, &minor))
|
||||||
{
|
{
|
||||||
g_warning ("Could not get device info for fd %d: %m", fd);
|
g_warning ("Could not get device info for fd %d: %m", fd);
|
||||||
@ -540,6 +558,7 @@ meta_launcher_new (GError **error)
|
|||||||
self = g_slice_new0 (MetaLauncher);
|
self = g_slice_new0 (MetaLauncher);
|
||||||
self->session_proxy = g_object_ref (session_proxy);
|
self->session_proxy = g_object_ref (session_proxy);
|
||||||
self->seat_proxy = g_object_ref (seat_proxy);
|
self->seat_proxy = g_object_ref (seat_proxy);
|
||||||
|
self->sysfs_fds = g_hash_table_new (NULL, NULL);
|
||||||
|
|
||||||
self->session_active = TRUE;
|
self->session_active = TRUE;
|
||||||
self->kms_fd = kms_fd;
|
self->kms_fd = kms_fd;
|
||||||
@ -565,6 +584,7 @@ meta_launcher_free (MetaLauncher *self)
|
|||||||
{
|
{
|
||||||
g_object_unref (self->seat_proxy);
|
g_object_unref (self->seat_proxy);
|
||||||
g_object_unref (self->session_proxy);
|
g_object_unref (self->session_proxy);
|
||||||
|
g_hash_table_destroy (self->sysfs_fds);
|
||||||
g_free (self->kms_file_path);
|
g_free (self->kms_file_path);
|
||||||
g_slice_free (MetaLauncher, self);
|
g_slice_free (MetaLauncher, self);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user