libinput: don't use weston_config when configuring input devices

Instead add callbacks to the drm and fbdev backends and pass that to
the input backens so that when a new device needs to be configured
that is called and the compositor can configure it.

Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
diff --git a/src/main.c b/src/main.c
index 4e78e91..6a94c76 100644
--- a/src/main.c
+++ b/src/main.c
@@ -38,6 +38,7 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/socket.h>
+#include <libinput.h>
 
 #ifdef HAVE_LIBUNWIND
 #define UNW_LOCAL_ONLY
@@ -873,6 +874,30 @@
 	return mode;
 }
 
+static void
+configure_input_device(struct weston_compositor *compositor,
+		       struct libinput_device *device)
+{
+	struct weston_config_section *s;
+	struct weston_config *config = wet_get_config(compositor);
+	int enable_tap;
+	int enable_tap_default;
+
+	s = weston_config_get_section(config,
+				      "libinput", NULL, NULL);
+
+	if (libinput_device_config_tap_get_finger_count(device) > 0) {
+		enable_tap_default =
+			libinput_device_config_tap_get_default_enabled(
+				device);
+		weston_config_section_get_bool(s, "enable_tap",
+					       &enable_tap,
+					       enable_tap_default);
+		libinput_device_config_tap_set_enabled(device,
+						       enable_tap);
+	}
+}
+
 static int
 load_drm_backend(struct weston_compositor *c, const char *backend,
 		 int *argc, char **argv, struct weston_config *wc)
@@ -899,6 +924,7 @@
 	config.base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION;
 	config.base.struct_size = sizeof(struct weston_drm_backend_config);
 	config.configure_output = drm_configure_output;
+	config.configure_device = configure_input_device;
 
 	ret = load_backend_new(c, backend, &config.base);
 
@@ -1021,6 +1047,7 @@
 
 	config.base.struct_version = WESTON_FBDEV_BACKEND_CONFIG_VERSION;
 	config.base.struct_size = sizeof(struct weston_fbdev_backend_config);
+	config.configure_device = configure_input_device;
 
 	/* load the actual wayland backend and configure it */
 	ret = load_backend_new(c, backend, &config.base);