mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-07 06:30:15 +01:00
libinput: initialize the quirks subsystem
A bit quirky (haha), because we cannot do this during context creation - we really want any parsing error messages to show up in the right log file and the log handler isn't set up during context creation. So we do it on the first real call to the backend - path_add_device or udev_assign_seat. Also, failure to initialize the quirks subsystem just means we continue as normal. This shouldn't be a hard failure, it just means a lot of devices won't work properly. If the LIBINPUT_DATA_DIR environment variable is set, that directory is used for the data file. Only that directory, no custom override file in that case. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
12b07229d8
commit
33341ddd20
4 changed files with 62 additions and 0 deletions
|
|
@ -140,6 +140,9 @@ struct libinput {
|
|||
struct list device_group_list;
|
||||
|
||||
uint64_t last_event_time;
|
||||
|
||||
bool quirks_initialized;
|
||||
struct quirks_context *quirks;
|
||||
};
|
||||
|
||||
typedef void (*libinput_seat_destroy_func) (struct libinput_seat *seat);
|
||||
|
|
@ -427,6 +430,9 @@ libinput_init(struct libinput *libinput,
|
|||
const struct libinput_interface_backend *interface_backend,
|
||||
void *user_data);
|
||||
|
||||
void
|
||||
libinput_init_quirks(struct libinput *libinput);
|
||||
|
||||
struct libinput_source *
|
||||
libinput_add_fd(struct libinput *libinput,
|
||||
int fd,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "libinput-private.h"
|
||||
#include "evdev.h"
|
||||
#include "timer.h"
|
||||
#include "quirks.h"
|
||||
|
||||
#define require_event_type(li_, type_, retval_, ...) \
|
||||
if (type_ == LIBINPUT_EVENT_NONE) abort(); \
|
||||
|
|
@ -1720,6 +1721,46 @@ libinput_init(struct libinput *libinput,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
libinput_init_quirks(struct libinput *libinput)
|
||||
{
|
||||
const char *data_path,
|
||||
*override_file = NULL;
|
||||
struct quirks_context *quirks;
|
||||
|
||||
if (libinput->quirks_initialized)
|
||||
return;
|
||||
|
||||
/* If we fail, we'll fail next time too */
|
||||
libinput->quirks_initialized = true;
|
||||
|
||||
data_path = getenv("LIBINPUT_DATA_DIR");
|
||||
if (!data_path) {
|
||||
data_path = LIBINPUT_DATA_DIR;
|
||||
override_file = LIBINPUT_DATA_OVERRIDE_FILE;
|
||||
}
|
||||
|
||||
quirks = quirks_init_subsystem(data_path,
|
||||
override_file,
|
||||
log_msg_va,
|
||||
libinput,
|
||||
QLOG_LIBINPUT_LOGGING);
|
||||
if (!quirks) {
|
||||
log_error(libinput,
|
||||
"Failed to load the device quirks from %s%s%s. "
|
||||
"This will negatively affect device behavior. "
|
||||
"See %sdevice-quirks.html for details.\n",
|
||||
data_path,
|
||||
override_file ? " and " : "",
|
||||
override_file ? override_file : "",
|
||||
HTTP_DOC_LINK
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
libinput->quirks = quirks;
|
||||
}
|
||||
|
||||
static void
|
||||
libinput_device_destroy(struct libinput_device *device);
|
||||
|
||||
|
|
@ -1791,6 +1832,7 @@ libinput_unref(struct libinput *libinput)
|
|||
|
||||
libinput_timer_subsys_destroy(libinput);
|
||||
libinput_drop_destroyed_sources(libinput);
|
||||
quirks_context_unref(libinput->quirks);
|
||||
close(libinput->epoll_fd);
|
||||
free(libinput);
|
||||
|
||||
|
|
|
|||
|
|
@ -337,6 +337,13 @@ libinput_path_add_device(struct libinput *libinput,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* We cannot do this during path_create_context because the log
|
||||
* handler isn't set up there but we really want to log to the right
|
||||
* place if the quirks run into parser errors. So we have to do it
|
||||
* on the first call to add_device.
|
||||
*/
|
||||
libinput_init_quirks(libinput);
|
||||
|
||||
udev_device = udev_device_from_devnode(libinput, udev, path);
|
||||
if (!udev_device) {
|
||||
log_bug_client(libinput, "Invalid path %s\n", path);
|
||||
|
|
|
|||
|
|
@ -382,6 +382,13 @@ libinput_udev_assign_seat(struct libinput *libinput,
|
|||
{
|
||||
struct udev_input *input = (struct udev_input*)libinput;
|
||||
|
||||
/* We cannot do this during udev_create_context because the log
|
||||
* handler isn't set up there but we really want to log to the right
|
||||
* place if the quirks run into parser errors. So we have to do it
|
||||
* here since we can expect the log handler to be set up by now.
|
||||
*/
|
||||
libinput_init_quirks(libinput);
|
||||
|
||||
if (!seat_id)
|
||||
return -1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue