[PATCH weston v3 05/11] compositor: remove the weston_config field from weston_compositor

Giulio Camuffo giuliocamuffo at gmail.com
Sat Jun 27 04:07:45 PDT 2015


Instead of the central weston_config pointer we now store it in some
module-specific pointers. This way we can remove them one by one.
---
 desktop-shell/shell.c               |  8 +++---
 desktop-shell/shell.h               |  1 +
 fullscreen-shell/fullscreen-shell.c |  3 ++-
 ivi-shell/hmi-controller.c          | 18 +++++++------
 ivi-shell/ivi-layout-private.h      |  2 +-
 ivi-shell/ivi-layout.c              |  4 ++-
 ivi-shell/ivi-shell.c               | 13 +++++-----
 src/cms-colord.c                    |  3 ++-
 src/cms-static.c                    |  7 ++++--
 src/compositor-drm.c                | 16 ++++++++++++
 src/compositor-drm.h                |  6 +++++
 src/compositor-fbdev.c              | 16 ++++++++++++
 src/compositor-fbdev.h              |  6 +++++
 src/compositor-rpi.c                | 17 +++++++++++++
 src/compositor-rpi.h                |  6 +++++
 src/compositor.h                    |  7 +++---
 src/libinput-device.c               | 29 +--------------------
 src/libinput-device.h               |  2 ++
 src/libinput-seat.c                 | 10 ++++++++
 src/libinput-seat.h                 |  6 +++++
 src/main.c                          | 50 +++++++++++++++++++++++++++++++------
 src/text-backend.c                  | 10 +++++---
 tests/ivi_layout-internal-test.c    |  2 ++
 tests/ivi_layout-test-plugin.c      |  2 ++
 tests/surface-global-test.c         |  3 ++-
 tests/surface-screenshot.c          |  7 +++---
 tests/surface-test.c                |  3 ++-
 tests/weston-test.c                 |  3 ++-
 xwayland/launcher.c                 |  6 +++--
 xwayland/xwayland.h                 |  1 +
 30 files changed, 194 insertions(+), 73 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index ed7e896..165d8a5 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -610,7 +610,7 @@ shell_configuration(struct desktop_shell *shell)
 	char *s, *client;
 	int ret;
 
-	section = weston_config_get_section(shell->compositor->config,
+	section = weston_config_get_section(shell->config,
 					    "shell", NULL, NULL);
 	ret = asprintf(&client, "%s/%s", weston_config_get_libexec_dir(),
 		       WESTON_SHELL_CLIENT);
@@ -6467,7 +6467,8 @@ handle_seat_created(struct wl_listener *listener, void *data)
 
 WL_EXPORT int
 module_init(struct weston_compositor *ec,
-	    int *argc, char *argv[])
+	    int *argc, char *argv[],
+	    struct weston_config *config)
 {
 	struct weston_seat *seat;
 	struct desktop_shell *shell;
@@ -6480,6 +6481,7 @@ module_init(struct weston_compositor *ec,
 		return -1;
 
 	shell->compositor = ec;
+	shell->config = config;
 
 	shell->destroy_listener.notify = shell_destroy;
 	wl_signal_add(&ec->destroy_signal, &shell->destroy_listener);
@@ -6514,7 +6516,7 @@ module_init(struct weston_compositor *ec,
 	if (input_panel_setup(shell) < 0)
 		return -1;
 
-	shell->text_backend = text_backend_init(ec);
+	shell->text_backend = text_backend_init(ec, config);
 	if (!shell->text_backend)
 		return -1;
 
diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h
index c0585a2..ba7d2cb 100644
--- a/desktop-shell/shell.h
+++ b/desktop-shell/shell.h
@@ -118,6 +118,7 @@ struct shell_output {
 
 struct desktop_shell {
 	struct weston_compositor *compositor;
+	struct weston_config *config;
 
 	struct wl_listener idle_listener;
 	struct wl_listener wake_listener;
diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c
index ab9c420..ceda027 100644
--- a/fullscreen-shell/fullscreen-shell.c
+++ b/fullscreen-shell/fullscreen-shell.c
@@ -791,7 +791,8 @@ bind_fullscreen_shell(struct wl_client *client, void *data, uint32_t version,
 
 WL_EXPORT int
 module_init(struct weston_compositor *compositor,
-	    int *argc, char *argv[])
+	    int *argc, char *argv[],
+	    struct weston_config *config)
 {
 	struct fullscreen_shell *shell;
 	struct weston_seat *seat;
diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index eae346a..10e385e 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -120,6 +120,7 @@ struct hmi_controller {
 	int32_t                             is_initialized;
 
 	struct weston_compositor           *compositor;
+	struct weston_config               *config;
 	struct wl_listener                  destroy_listener;
 
 	struct wl_client                   *user_interface;
@@ -137,6 +138,7 @@ const struct ivi_controller_interface *ivi_controller_interface;
 int
 controller_module_init(struct weston_compositor *ec,
 		       int *argc, char *argv[],
+		       struct weston_config *config,
 		       const struct ivi_controller_interface *interface,
 		       size_t interface_version);
 
@@ -595,10 +597,9 @@ set_notification_configure_surface(struct ivi_layout_surface *ivisurf,
  * of ivi_layers are initialized in hmi_controller_create
  */
 static struct hmi_server_setting *
-hmi_server_setting_create(struct weston_compositor *ec)
+hmi_server_setting_create(struct weston_config *config)
 {
 	struct hmi_server_setting *setting = MEM_ALLOC(sizeof(*setting));
-	struct weston_config *config = ec->config;
 	struct weston_config_section *shell_section = NULL;
 
 	shell_section = weston_config_get_section(config, "ivi-shell",
@@ -665,7 +666,8 @@ hmi_controller_destroy(struct wl_listener *listener, void *data)
  * ivi_hmi_controller_home is requested.
  */
 static struct hmi_controller *
-hmi_controller_create(struct weston_compositor *ec)
+hmi_controller_create(struct weston_compositor *ec,
+                      struct weston_config *config)
 {
 	struct ivi_layout_screen **pp_screen = NULL;
 	struct ivi_layout_screen *iviscrn  = NULL;
@@ -678,8 +680,9 @@ hmi_controller_create(struct weston_compositor *ec)
 
 	wl_array_init(&hmi_ctrl->ui_widgets);
 	hmi_ctrl->layout_mode = IVI_HMI_CONTROLLER_LAYOUT_MODE_TILING;
-	hmi_ctrl->hmi_setting = hmi_server_setting_create(ec);
+	hmi_ctrl->hmi_setting = hmi_server_setting_create(config);
 	hmi_ctrl->compositor = ec;
+	hmi_ctrl->config = config;
 
 	ivi_controller_interface->get_screens(&screen_length, &pp_screen);
 
@@ -1021,7 +1024,7 @@ ivi_hmi_controller_add_launchers(struct hmi_controller *hmi_ctrl,
 	if (0 == y_count)
 		y_count  = 1;
 
-	config = hmi_ctrl->compositor->config;
+	config = hmi_ctrl->config;
 	if (!config)
 		return;
 
@@ -1691,7 +1694,7 @@ initialize(struct hmi_controller *hmi_ctrl)
 		uint32_t *dest;
 	};
 
-	struct weston_config *config = hmi_ctrl->compositor->config;
+	struct weston_config *config = hmi_ctrl->config;
 	struct weston_config_section *section = NULL;
 	int result = 0;
 	int i = 0;
@@ -1748,6 +1751,7 @@ launch_hmi_client_process(void *data)
 WL_EXPORT int
 controller_module_init(struct weston_compositor *ec,
 		       int *argc, char *argv[],
+		       struct weston_config *config,
 		       const struct ivi_controller_interface *interface,
 		       size_t interface_version)
 {
@@ -1761,7 +1765,7 @@ controller_module_init(struct weston_compositor *ec,
 
 	ivi_controller_interface = interface;
 
-	hmi_ctrl = hmi_controller_create(ec);
+	hmi_ctrl = hmi_controller_create(ec, config);
 
 	if (!initialize(hmi_ctrl)) {
 		return -1;
diff --git a/ivi-shell/ivi-layout-private.h b/ivi-shell/ivi-layout-private.h
index cf2db7d..b8ef498 100644
--- a/ivi-shell/ivi-layout-private.h
+++ b/ivi-shell/ivi-layout-private.h
@@ -226,7 +226,7 @@ void
 ivi_layout_transition_move_layer_cancel(struct ivi_layout_layer *layer);
 int
 load_controller_modules(struct weston_compositor *compositor, const char *modules,
-			int *argc, char *argv[]);
+			int *argc, char *argv[], struct weston_config *config);
 void
 ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf);
 #endif
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 5f9235c..dcf0687 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -3068,12 +3068,13 @@ static struct ivi_controller_interface ivi_controller_interface = {
 
 int
 load_controller_modules(struct weston_compositor *compositor, const char *modules,
-			int *argc, char *argv[])
+			int *argc, char *argv[], struct weston_config *config)
 {
 	const char *p, *end;
 	char buffer[256];
 	int (*controller_module_init)(struct weston_compositor *compositor,
 				      int *argc, char *argv[],
+				      struct weston_config *config,
 				      const struct ivi_controller_interface *interface,
 				      size_t interface_version);
 
@@ -3090,6 +3091,7 @@ load_controller_modules(struct weston_compositor *compositor, const char *module
 			return -1;
 
 		if (controller_module_init(compositor, argc, argv,
+					   config,
 					   &ivi_controller_interface,
 				sizeof(struct ivi_controller_interface)) != 0) {
 			weston_log("ivi-shell: Initialization of controller module fails");
diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index f958fd4..4ae2b03 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -385,11 +385,10 @@ init_ivi_shell(struct weston_compositor *compositor, struct ivi_shell *shell,
 
 static int
 ivi_shell_setting_create(struct ivi_shell_setting *dest,
-			 struct weston_compositor *compositor,
+			 struct weston_config *config,
 			 int *argc, char *argv[])
 {
 	int result = 0;
-	struct weston_config *config = compositor->config;
 	struct weston_config_section *section;
 
 	const struct weston_option ivi_shell_options[] = {
@@ -419,7 +418,8 @@ ivi_shell_setting_create(struct ivi_shell_setting *dest,
  */
 WL_EXPORT int
 module_init(struct weston_compositor *compositor,
-	    int *argc, char *argv[])
+           int *argc, char *argv[],
+           struct weston_config *config)
 {
 	struct ivi_shell *shell;
 	struct ivi_shell_setting setting = { };
@@ -429,7 +429,7 @@ module_init(struct weston_compositor *compositor,
 	if (shell == NULL)
 		return -1;
 
-	if (ivi_shell_setting_create(&setting, compositor, argc, argv) != 0)
+	if (ivi_shell_setting_create(&setting, config, argc, argv) != 0)
 		return -1;
 
 	init_ivi_shell(compositor, shell, &setting);
@@ -440,7 +440,7 @@ module_init(struct weston_compositor *compositor,
 	if (input_panel_setup(shell) < 0)
 		goto out_settings;
 
-	shell->text_backend = text_backend_init(compositor);
+	shell->text_backend = text_backend_init(compositor, config);
 	if (!shell->text_backend)
 		goto out_settings;
 
@@ -452,8 +452,7 @@ module_init(struct weston_compositor *compositor,
 	ivi_layout_init_with_compositor(compositor);
 
 	/* Call module_init of ivi-modules which are defined in weston.ini */
-	if (load_controller_modules(compositor, setting.ivi_module,
-				    argc, argv) < 0)
+	if (load_controller_modules(compositor, setting.ivi_module, argc, argv, config) < 0)
 		goto out_settings;
 
 	retval = 0;
diff --git a/src/cms-colord.c b/src/cms-colord.c
index 2adc886..954f9e6 100644
--- a/src/cms-colord.c
+++ b/src/cms-colord.c
@@ -483,7 +483,8 @@ colord_cms_output_destroy(gpointer data)
 
 WL_EXPORT int
 module_init(struct weston_compositor *ec,
-	    int *argc, char *argv[])
+	    int *argc, char *argv[],
+	    struct weston_config *config)
 {
 	gboolean ret;
 	GError *error = NULL;
diff --git a/src/cms-static.c b/src/cms-static.c
index 7166f57..74465a7 100644
--- a/src/cms-static.c
+++ b/src/cms-static.c
@@ -36,6 +36,7 @@ struct cms_static {
 	struct weston_compositor	*ec;
 	struct wl_listener		 destroy_listener;
 	struct wl_listener		 output_created_listener;
+	struct weston_config		*config;
 };
 
 static void
@@ -49,7 +50,7 @@ cms_output_created(struct cms_static *cms, struct weston_output *o)
 
 	if (o->name == NULL)
 		return;
-	s = weston_config_get_section(cms->ec->config,
+	s = weston_config_get_section(cms->config,
 				      "output", "name", o->name);
 	if (s == NULL)
 		return;
@@ -90,7 +91,8 @@ cms_notifier_destroy(struct wl_listener *listener, void *data)
 
 WL_EXPORT int
 module_init(struct weston_compositor *ec,
-	    int *argc, char *argv[])
+	    int *argc, char *argv[],
+	    struct weston_config *config)
 {
 	struct cms_static *cms;
 	struct weston_output *output;
@@ -103,6 +105,7 @@ module_init(struct weston_compositor *ec,
 		return -1;
 
 	cms->ec = ec;
+	cms->config = config;
 	cms->destroy_listener.notify = cms_notifier_destroy;
 	wl_signal_add(&ec->destroy_signal, &cms->destroy_listener);
 
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 8f34521..f47ef29 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -129,6 +129,8 @@ struct drm_backend {
 				 struct weston_drm_backend_output_config *config,
 				 int (*parse_modeline)(const char *s,
 				   struct weston_drm_backend_modeline *modeline));
+	void (*configure_input_device)(struct weston_compositor *compositor,
+			struct weston_drm_backend_input_device_config *config);
 };
 
 struct drm_mode {
@@ -2764,6 +2766,18 @@ renderer_switch_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
 	switch_to_gl_renderer(b);
 }
 
+static void
+drm_configure_device(struct weston_compositor *compositor,
+		     struct weston_libinput_device_config *config)
+{
+	struct drm_backend *b = (struct drm_backend *)compositor->backend;
+	struct weston_drm_backend_input_device_config c = {
+		.enable_tap = config->enable_tap,
+	};
+	b->configure_input_device(compositor, &c);
+	config->enable_tap = c.enable_tap;
+}
+
 static struct drm_backend *
 drm_backend_create(struct weston_compositor *compositor,
 		   struct weston_drm_backend_config *config)
@@ -2796,6 +2810,7 @@ drm_backend_create(struct weston_compositor *compositor,
 	b->use_pixman = config->use_pixman;
 	b->configure_output = config->configure_output;
 	b->option_current_mode = config->default_current_mode;
+	b->configure_input_device = config->configure_input_device;
 
 	if (parse_gbm_format(config->format, GBM_FORMAT_XRGB8888, &b->format) < 0)
 		goto err_compositor;
@@ -2858,6 +2873,7 @@ drm_backend_create(struct weston_compositor *compositor,
 	wl_list_init(&b->sprite_list);
 	create_sprites(b);
 
+	b->input.configure_device = drm_configure_device;
 	if (udev_input_init(&b->input,
 			    compositor, b->udev, seat_id) < 0) {
 		weston_log("failed to create input devices\n");
diff --git a/src/compositor-drm.h b/src/compositor-drm.h
index 5c5a3f9..a9b4fa7 100644
--- a/src/compositor-drm.h
+++ b/src/compositor-drm.h
@@ -54,6 +54,10 @@ struct weston_drm_backend_output_config {
 	struct weston_drm_backend_modeline *modeline;
 };
 
+struct weston_drm_backend_input_device_config {
+	bool enable_tap;
+};
+
 struct weston_drm_backend_config {
 	struct weston_backend_config base;
 
@@ -68,6 +72,8 @@ struct weston_drm_backend_config {
 				 struct weston_drm_backend_output_config *config,
 				 int (*parse_modeline)(const char *s,
 				   struct weston_drm_backend_modeline *modeline));
+	void (*configure_input_device)(struct weston_compositor *compositor,
+			struct weston_drm_backend_input_device_config *config);
 };
 
 #ifdef  __cplusplus
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index c0833ca..db4d4f7 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -64,6 +64,8 @@ struct fbdev_backend {
 	void (*configure_output)(struct weston_compositor *compositor,
 				 const char *name,
 				 struct weston_fbdev_backend_output_config *config);
+	void (*configure_input_device)(struct weston_compositor *compositor,
+			struct weston_fbdev_backend_input_device_config *config);
 };
 
 struct fbdev_screeninfo {
@@ -803,6 +805,18 @@ switch_vt_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *d
 	weston_launcher_activate_vt(compositor->launcher, key - KEY_F1 + 1);
 }
 
+static void
+fbdev_configure_device(struct weston_compositor *compositor,
+		       struct weston_libinput_device_config *config)
+{
+	struct fbdev_backend *b = (struct fbdev_backend *)compositor->backend;
+	struct weston_fbdev_backend_input_device_config c = {
+		.enable_tap = config->enable_tap,
+	};
+	b->configure_input_device(compositor, &c);
+	config->enable_tap = c.enable_tap;
+}
+
 static struct fbdev_backend *
 fbdev_backend_create(struct weston_compositor *compositor,
                      struct weston_fbdev_backend_config *config)
@@ -848,6 +862,7 @@ fbdev_backend_create(struct weston_compositor *compositor,
 	backend->prev_state = WESTON_COMPOSITOR_ACTIVE;
 	backend->use_pixman = !config->use_gl;
 	backend->configure_output = config->configure_output;
+	backend->configure_input_device = config->configure_input_device;
 
 	for (key = KEY_F1; key < KEY_F9; key++)
 		weston_compositor_add_key_binding(compositor, key,
@@ -879,6 +894,7 @@ fbdev_backend_create(struct weston_compositor *compositor,
 	if (fbdev_output_create(backend, device) < 0)
 		goto out_pixman;
 
+	backend->input.configure_device = fbdev_configure_device;
 	udev_input_init(&backend->input, compositor, backend->udev, seat_id);
 
 	compositor->backend = &backend->base;
diff --git a/src/compositor-fbdev.h b/src/compositor-fbdev.h
index 736d56c..fa6dff6 100644
--- a/src/compositor-fbdev.h
+++ b/src/compositor-fbdev.h
@@ -40,6 +40,10 @@ struct weston_fbdev_backend_output_config {
 	struct weston_backend_output_config base;
 };
 
+struct weston_fbdev_backend_input_device_config {
+	bool enable_tap;
+};
+
 struct weston_fbdev_backend_config {
 	struct weston_backend_config base;
 
@@ -49,6 +53,8 @@ struct weston_fbdev_backend_config {
 	void (*configure_output)(struct weston_compositor *compositor,
 				 const char *name,
 				 struct weston_fbdev_backend_output_config *config);
+	void (*configure_input_device)(struct weston_compositor *compositor,
+			struct weston_fbdev_backend_input_device_config *config);
 };
 
 #ifdef  __cplusplus
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index c2bffe5..569233a 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -101,6 +101,9 @@ struct rpi_backend {
 	struct wl_listener session_listener;
 
 	int single_buffer;
+
+	void (*configure_input_device)(struct weston_compositor *compositor,
+			struct weston_rpi_backend_input_device_config *config);
 };
 
 static inline struct rpi_output *
@@ -456,6 +459,18 @@ switch_vt_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *d
 	weston_launcher_activate_vt(compositor->launcher, key - KEY_F1 + 1);
 }
 
+static void
+rpi_configure_device(struct weston_compositor *compositor,
+		     struct weston_libinput_device_config *config)
+{
+	struct rpi_backend *b = (struct rpi_backend *)compositor->backend;
+	struct weston_rpi_backend_input_device_config c = {
+		.enable_tap = config->enable_tap,
+	};
+	b->configure_input_device(compositor, &c);
+	config->enable_tap = c.enable_tap;
+}
+
 static struct rpi_backend *
 rpi_backend_create(struct weston_compositor *compositor,
 		   struct weston_rpi_backend_config *config)
@@ -496,6 +511,7 @@ rpi_backend_create(struct weston_compositor *compositor,
 
 	backend->prev_state = WESTON_COMPOSITOR_ACTIVE;
 	backend->single_buffer = config->single_buffer;
+	backend->configure_input_device = config->configure_input_device;
 
 	weston_log("Dispmanx planes are %s buffered.\n",
 		   backend->single_buffer ? "single" : "double");
@@ -522,6 +538,7 @@ rpi_backend_create(struct weston_compositor *compositor,
 	if (rpi_output_create(backend, config->output_transform) < 0)
 		goto out_renderer;
 
+	backend->input.configure_device = rpi_configure_device;
 	if (udev_input_init(&backend->input,
 			    compositor,
 			    backend->udev, "seat0") != 0) {
diff --git a/src/compositor-rpi.h b/src/compositor-rpi.h
index b3190c9..971e39a 100644
--- a/src/compositor-rpi.h
+++ b/src/compositor-rpi.h
@@ -35,6 +35,10 @@ extern "C" {
 
 #include "compositor.h"
 
+struct weston_rpi_backend_input_device_config {
+	bool enable_tap;
+};
+
 struct weston_rpi_backend_config {
 	struct weston_backend_config base;
 
@@ -42,6 +46,8 @@ struct weston_rpi_backend_config {
 	uint32_t output_transform;
 	int single_buffer;
 	int opaque_regions;
+	void (*configure_input_device)(struct weston_compositor *compositor,
+			struct weston_rpi_backend_input_device_config *config);
 };
 
 #ifdef  __cplusplus
diff --git a/src/compositor.h b/src/compositor.h
index 781653e..31ea5ed 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -627,7 +627,6 @@ struct weston_compositor {
 
 	struct wl_display *wl_display;
 	struct weston_shell_interface shell_interface;
-	struct weston_config *config;
 
 	/* surface signals */
 	struct wl_signal create_surface_signal;
@@ -1488,7 +1487,8 @@ clipboard_create(struct weston_seat *seat);
 struct text_backend;
 
 struct text_backend *
-text_backend_init(struct weston_compositor *ec);
+text_backend_init(struct weston_compositor *ec,
+		  struct weston_config *config);
 
 void
 text_backend_destroy(struct text_backend *text_backend);
@@ -1573,7 +1573,8 @@ backend_init(struct weston_compositor *c,
              struct weston_backend_config *config);
 int
 module_init(struct weston_compositor *compositor,
-	    int *argc, char *argv[]);
+	    int *argc, char *argv[],
+	    struct weston_config *config);
 
 void
 weston_transformed_coord(int width, int height,
diff --git a/src/libinput-device.c b/src/libinput-device.c
index 2cbfb88..25ce4a6 100644
--- a/src/libinput-device.c
+++ b/src/libinput-device.c
@@ -365,7 +365,7 @@ notify_output_destroy(struct wl_listener *listener, void *data)
  * can't do that, so we need to convert the calibration to the normalized
  * format libinput expects.
  */
-static void
+void
 evdev_device_set_calibration(struct evdev_device *device)
 {
 	struct udev *udev;
@@ -459,31 +459,6 @@ evdev_device_set_output(struct evdev_device *device,
 	evdev_device_set_calibration(device);
 }
 
-static void
-configure_device(struct evdev_device *device)
-{
-	struct weston_compositor *compositor = device->seat->compositor;
-	struct weston_config_section *s;
-	int enable_tap;
-	int enable_tap_default;
-
-	s = weston_config_get_section(compositor->config,
-				      "libinput", NULL, NULL);
-
-	if (libinput_device_config_tap_get_finger_count(device->device) > 0) {
-		enable_tap_default =
-			libinput_device_config_tap_get_default_enabled(
-				device->device);
-		weston_config_section_get_bool(s, "enable_tap",
-					       &enable_tap,
-					       enable_tap_default);
-		libinput_device_config_tap_set_enabled(device->device,
-						       enable_tap);
-	}
-
-	evdev_device_set_calibration(device);
-}
-
 struct evdev_device *
 evdev_device_create(struct libinput_device *libinput_device,
 		    struct weston_seat *seat)
@@ -517,8 +492,6 @@ evdev_device_create(struct libinput_device *libinput_device,
 	libinput_device_set_user_data(libinput_device, device);
 	libinput_device_ref(libinput_device);
 
-	configure_device(device);
-
 	return device;
 }
 
diff --git a/src/libinput-device.h b/src/libinput-device.h
index a3848ca..f92f6a8 100644
--- a/src/libinput-device.h
+++ b/src/libinput-device.h
@@ -66,6 +66,8 @@ void
 evdev_device_set_output(struct evdev_device *device,
 			struct weston_output *output);
 void
+evdev_device_set_calibration(struct evdev_device *device);
+void
 evdev_device_destroy(struct evdev_device *device);
 
 void
diff --git a/src/libinput-seat.c b/src/libinput-seat.c
index ce79d34..6596f35 100644
--- a/src/libinput-seat.c
+++ b/src/libinput-seat.c
@@ -60,6 +60,7 @@ device_added(struct udev_input *input, struct libinput_device *libinput_device)
 	struct libinput_seat *libinput_seat;
 	struct weston_seat *seat;
 	struct udev_seat *udev_seat;
+	struct weston_libinput_device_config config;
 
 	c = input->compositor;
 	libinput_seat = libinput_device_get_seat(libinput_device);
@@ -74,6 +75,15 @@ device_added(struct udev_input *input, struct libinput_device *libinput_device)
 	if (device == NULL)
 		return;
 
+	if (input->configure_device != NULL) {
+		config.enable_tap =
+			libinput_device_config_tap_get_finger_count(device->device) &&
+			libinput_device_config_tap_get_default_enabled(device->device);
+		input->configure_device(c, &config);
+		libinput_device_config_tap_set_enabled(device->device,
+						       config.enable_tap);
+	}
+	evdev_device_set_calibration(device);
 	udev_seat = (struct udev_seat *) seat;
 	wl_list_insert(udev_seat->devices_list.prev, &device->link);
 
diff --git a/src/libinput-seat.h b/src/libinput-seat.h
index 0813189..9aa8474 100644
--- a/src/libinput-seat.h
+++ b/src/libinput-seat.h
@@ -39,11 +39,17 @@ struct udev_seat {
 	struct wl_listener output_create_listener;
 };
 
+struct weston_libinput_device_config {
+	bool enable_tap;
+};
+
 struct udev_input {
 	struct libinput *libinput;
 	struct wl_event_source *libinput_source;
 	struct weston_compositor *compositor;
 	int suspended;
+	void (*configure_device)(struct weston_compositor *compositor,
+				 struct weston_libinput_device_config *config);
 };
 
 int
diff --git a/src/main.c b/src/main.c
index d629c58..9066dba 100644
--- a/src/main.c
+++ b/src/main.c
@@ -472,12 +472,13 @@ weston_create_listening_socket(struct wl_display *display, const char *socket_na
 
 static int
 load_modules(struct weston_compositor *ec, const char *modules,
-	     int *argc, char *argv[])
+	     int *argc, char *argv[], struct weston_config *config)
 {
 	const char *p, *end;
 	char buffer[256];
 	int (*module_init)(struct weston_compositor *ec,
-			   int *argc, char *argv[]);
+			   int *argc, char *argv[],
+			   struct weston_config *config);
 
 	if (modules == NULL)
 		return 0;
@@ -489,7 +490,7 @@ load_modules(struct weston_compositor *ec, const char *modules,
 		module_init = weston_load_module(buffer, "module_init");
 		if (!module_init)
 			return -1;
-		if (module_init(ec, argc, argv) < 0)
+		if (module_init(ec, argc, argv, config) < 0)
 			return -1;
 		p = end;
 		while (*p == ',')
@@ -938,6 +939,18 @@ cleanup:
 }
 
 static void
+configure_libinput_device(struct weston_compositor *c, bool *enable_tap)
+{
+	struct weston_config *wc = weston_compositor_get_user_data(c);
+	struct weston_config_section *s;
+
+	s = weston_config_get_section(wc, "libinput", NULL, NULL);
+	weston_config_section_get_bool(s, "enable_tap",
+				       (int *)enable_tap,
+				       *enable_tap);
+}
+
+static void
 drm_configure_output(struct weston_compositor *c, const char *name,
 		     struct weston_drm_backend_output_config *config,
 		     int (*parse_modeline)(const char *s,
@@ -979,6 +992,13 @@ drm_configure_output(struct weston_compositor *c, const char *name,
 	weston_config_section_get_string(section, "seat", &config->seat, "");
 }
 
+static void
+drm_configure_input_device(struct weston_compositor *c,
+			struct weston_drm_backend_input_device_config *config)
+{
+	configure_libinput_device(c, &config->enable_tap);
+}
+
 static int
 init_drm_backend(struct weston_compositor *c, const char *backend,
 		 int *argc, char **argv, struct weston_config *wc)
@@ -991,6 +1011,7 @@ init_drm_backend(struct weston_compositor *c, const char *backend,
 		.tty = 0,
 		.default_current_mode = false,
 		.configure_output = drm_configure_output,
+		.configure_input_device = drm_configure_input_device,
 	};
 	struct weston_config_section *section;
 	char *format = NULL, *seat = NULL;
@@ -1040,6 +1061,13 @@ fbdev_configure_output(struct weston_compositor *c, const char *name,
 	free(s);
 }
 
+static void
+fbdev_configure_input_device(struct weston_compositor *c,
+			struct weston_fbdev_backend_input_device_config *config)
+{
+	configure_libinput_device(c, &config->enable_tap);
+}
+
 static int
 init_fbdev_backend(struct weston_compositor *c, const char *backend,
 		 int *argc, char **argv, struct weston_config *wc)
@@ -1049,6 +1077,7 @@ init_fbdev_backend(struct weston_compositor *c, const char *backend,
 		.device = NULL,
 		.tty = 0,
 		.configure_output = fbdev_configure_output,
+		.configure_input_device = fbdev_configure_input_device,
 	};
 	int ret = 0;
 	char *device = NULL;
@@ -1119,6 +1148,13 @@ cleanup:
 	return ret;
 }
 
+static void
+rpi_configure_input_device(struct weston_compositor *c,
+			struct weston_rpi_backend_input_device_config *config)
+{
+	configure_libinput_device(c, &config->enable_tap);
+}
+
 static int
 init_rpi_backend(struct weston_compositor *c, const char *backend,
 		 int *argc, char **argv, struct weston_config *wc)
@@ -1128,6 +1164,7 @@ init_rpi_backend(struct weston_compositor *c, const char *backend,
 		.single_buffer = false,
 		.opaque_regions = false,
 		.output_transform = WL_OUTPUT_TRANSFORM_NORMAL,
+		.configure_input_device = rpi_configure_input_device,
 	};
 	char *transform = NULL;
 	int ret = 0;
@@ -1307,7 +1344,6 @@ int main(int argc, char *argv[])
 		goto out_signals;
 	}
 
-	ec->config = config;
 	if (weston_compositor_init_config(ec, config) < 0)
 		goto out;
 	if (init_backend(ec, backend, &argc, argv, config) < 0)
@@ -1355,14 +1391,14 @@ int main(int argc, char *argv[])
 		weston_config_section_get_string(section, "shell", &shell,
 						 "desktop-shell.so");
 
-	if (load_modules(ec, shell, &argc, argv) < 0)
+	if (load_modules(ec, shell, &argc, argv, config) < 0)
 		goto out;
 
 	weston_config_section_get_string(section, "modules", &modules, "");
-	if (load_modules(ec, modules, &argc, argv) < 0)
+	if (load_modules(ec, modules, &argc, argv, config) < 0)
 		goto out;
 
-	if (load_modules(ec, option_modules, &argc, argv) < 0)
+	if (load_modules(ec, option_modules, &argc, argv, config) < 0)
 		goto out;
 
 	section = weston_config_get_section(config, "keyboard", NULL, NULL);
diff --git a/src/text-backend.c b/src/text-backend.c
index 9485f7e..790491b 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -1018,13 +1018,14 @@ handle_seat_created(struct wl_listener *listener, void *data)
 }
 
 static void
-text_backend_configuration(struct text_backend *text_backend)
+text_backend_configuration(struct text_backend *text_backend,
+			   struct weston_config *config)
 {
 	struct weston_config_section *section;
 	char *client;
 	int ret;
 
-	section = weston_config_get_section(text_backend->compositor->config,
+	section = weston_config_get_section(config,
 					    "input-method", NULL, NULL);
 	ret = asprintf(&client, "%s/weston-keyboard",
 		       weston_config_get_libexec_dir());
@@ -1047,7 +1048,8 @@ text_backend_destroy(struct text_backend *text_backend)
 }
 
 WL_EXPORT struct text_backend *
-text_backend_init(struct weston_compositor *ec)
+text_backend_init(struct weston_compositor *ec,
+	    struct weston_config *config)
 {
 	struct text_backend *text_backend;
 	struct weston_seat *seat;
@@ -1058,7 +1060,7 @@ text_backend_init(struct weston_compositor *ec)
 
 	text_backend->compositor = ec;
 
-	text_backend_configuration(text_backend);
+	text_backend_configuration(text_backend, config);
 
 	wl_list_for_each(seat, &ec->seat_list, link)
 		text_backend_seat_created(text_backend, seat);
diff --git a/tests/ivi_layout-internal-test.c b/tests/ivi_layout-internal-test.c
index bb9cce9..c228f50 100644
--- a/tests/ivi_layout-internal-test.c
+++ b/tests/ivi_layout-internal-test.c
@@ -1176,12 +1176,14 @@ run_internal_tests(void *data)
 int
 controller_module_init(struct weston_compositor *compositor,
 		       int *argc, char *argv[],
+		       struct weston_config *config,
 		       const struct ivi_controller_interface *iface,
 		       size_t iface_version);
 
 WL_EXPORT int
 controller_module_init(struct weston_compositor *compositor,
 		       int *argc, char *argv[],
+		       struct weston_config *config,
 		       const struct ivi_controller_interface *iface,
 		       size_t iface_version)
 {
diff --git a/tests/ivi_layout-test-plugin.c b/tests/ivi_layout-test-plugin.c
index 5ac0135..248946e 100644
--- a/tests/ivi_layout-test-plugin.c
+++ b/tests/ivi_layout-test-plugin.c
@@ -213,12 +213,14 @@ idle_launch_client(void *data)
 int
 controller_module_init(struct weston_compositor *compositor,
 		       int *argc, char *argv[],
+		       struct weston_config *config,
 		       const struct ivi_controller_interface *iface,
 		       size_t iface_version);
 
 WL_EXPORT int
 controller_module_init(struct weston_compositor *compositor,
 		       int *argc, char *argv[],
+		       struct weston_config *config,
 		       const struct ivi_controller_interface *iface,
 		       size_t iface_version)
 {
diff --git a/tests/surface-global-test.c b/tests/surface-global-test.c
index 11b2455..5c880bb 100644
--- a/tests/surface-global-test.c
+++ b/tests/surface-global-test.c
@@ -78,7 +78,8 @@ surface_to_from_global(void *data)
 }
 
 WL_EXPORT int
-module_init(struct weston_compositor *compositor, int *argc, char *argv[])
+module_init(struct weston_compositor *compositor, int *argc, char *argv[],
+	    struct weston_config *config)
 {
 	struct wl_event_loop *loop;
 
diff --git a/tests/surface-screenshot.c b/tests/surface-screenshot.c
index 06ef8d1..bf35893 100644
--- a/tests/surface-screenshot.c
+++ b/tests/surface-screenshot.c
@@ -212,10 +212,11 @@ out:
 }
 
 WL_EXPORT int
-module_init(struct weston_compositor *ec,
-	    int *argc, char *argv[])
+module_init(struct weston_compositor *compositor, int *argc, char *argv[],
+	    struct weston_config *config)
 {
-	weston_compositor_add_debug_binding(ec, KEY_H, trigger_binding, ec);
+	weston_compositor_add_debug_binding(compositor, KEY_H,
+	                                    trigger_binding, compositor);
 
 	return 0;
 }
diff --git a/tests/surface-test.c b/tests/surface-test.c
index 55c324b..73fd5a0 100644
--- a/tests/surface-test.c
+++ b/tests/surface-test.c
@@ -60,7 +60,8 @@ surface_transform(void *data)
 }
 
 WL_EXPORT int
-module_init(struct weston_compositor *compositor, int *argc, char *argv[])
+module_init(struct weston_compositor *compositor, int *argc, char *argv[],
+	    struct weston_config *config)
 {
 	struct wl_event_loop *loop;
 
diff --git a/tests/weston-test.c b/tests/weston-test.c
index df9a139..f49efff 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -575,7 +575,8 @@ idle_launch_client(void *data)
 
 WL_EXPORT int
 module_init(struct weston_compositor *ec,
-	    int *argc, char *argv[])
+	    int *argc, char *argv[],
+	    struct weston_config *config)
 {
 	struct weston_test *test;
 	struct wl_event_loop *loop;
diff --git a/xwayland/launcher.c b/xwayland/launcher.c
index db5e1d0..60b0bac 100644
--- a/xwayland/launcher.c
+++ b/xwayland/launcher.c
@@ -98,7 +98,7 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
 			goto fail;
 		snprintf(wm_fd, sizeof wm_fd, "%d", fd);
 
-		section = weston_config_get_section(wxs->compositor->config,
+		section = weston_config_get_section(wxs->config,
 						    "xwayland", NULL, NULL);
 		weston_config_section_get_string(section, "path",
 						 &xserver, XSERVER_PATH);
@@ -350,7 +350,8 @@ weston_xserver_destroy(struct wl_listener *l, void *data)
 
 WL_EXPORT int
 module_init(struct weston_compositor *compositor,
-	    int *argc, char *argv[])
+	    int *argc, char *argv[],
+	    struct weston_config *config)
 
 {
 	struct wl_display *display = compositor->wl_display;
@@ -398,6 +399,7 @@ module_init(struct weston_compositor *compositor,
 	weston_log("xserver listening on display %s\n", display_name);
 	setenv("DISPLAY", display_name, 1);
 
+	wxs->config = config;
 	wxs->loop = wl_display_get_event_loop(display);
 	wxs->abstract_source =
 		wl_event_loop_add_fd(wxs->loop, wxs->abstract_fd,
diff --git a/xwayland/xwayland.h b/xwayland/xwayland.h
index 7f4c5b1..48dc4bb 100644
--- a/xwayland/xwayland.h
+++ b/xwayland/xwayland.h
@@ -50,6 +50,7 @@ struct weston_xserver {
 	struct wl_client *client;
 	struct weston_compositor *compositor;
 	struct weston_wm *wm;
+	struct weston_config *config;
 	struct wl_listener destroy_listener;
 };
 
-- 
2.4.4



More information about the wayland-devel mailing list