[PATCH weston v2 4/8] compositor: remove the weston_config field in weston_compositor

Giulio Camuffo giuliocamuffo at gmail.com
Wed Jun 1 18:43:26 UTC 2016


The config can now be retrieved with a new function defined in weston.h,
weston_get_config(weston_compositor*).

Signed-off-by: Giulio Camuffo <giuliocamuffo at gmail.com>
---
 desktop-shell/shell.c      | 2 +-
 ivi-shell/hmi-controller.c | 6 +++---
 ivi-shell/ivi-shell.c      | 3 ++-
 src/cms-static.c           | 3 ++-
 src/compositor.h           | 1 -
 src/libinput-device.c      | 4 +++-
 src/main.c                 | 9 +++++++--
 src/text-backend.c         | 3 ++-
 src/weston.h               | 3 +++
 xwayland/launcher.c        | 5 +++--
 10 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index ec71cd1..e32f61e 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -640,7 +640,7 @@ shell_configuration(struct desktop_shell *shell)
 	int ret;
 	int allow_zap;
 
-	section = weston_config_get_section(shell->compositor->config,
+	section = weston_config_get_section(weston_get_config(shell->compositor),
 					    "shell", NULL, NULL);
 	ret = asprintf(&client, "%s/%s", weston_config_get_libexec_dir(),
 		       WESTON_SHELL_CLIENT);
diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 094682c..b479bb3 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -678,7 +678,7 @@ static struct hmi_server_setting *
 hmi_server_setting_create(struct weston_compositor *ec)
 {
 	struct hmi_server_setting *setting = MEM_ALLOC(sizeof(*setting));
-	struct weston_config *config = ec->config;
+	struct weston_config *config = weston_get_config(ec);
 	struct weston_config_section *shell_section = NULL;
 
 	shell_section = weston_config_get_section(config, "ivi-shell",
@@ -1140,7 +1140,7 @@ ivi_hmi_controller_add_launchers(struct hmi_controller *hmi_ctrl,
 	if (0 == y_count)
 		y_count  = 1;
 
-	config = hmi_ctrl->compositor->config;
+	config = weston_get_config(hmi_ctrl->compositor);
 	if (!config)
 		return;
 
@@ -1881,7 +1881,7 @@ initialize(struct hmi_controller *hmi_ctrl)
 		uint32_t *dest;
 	};
 
-	struct weston_config *config = hmi_ctrl->compositor->config;
+	struct weston_config *config = weston_get_config(hmi_ctrl->compositor);
 	struct weston_config_section *section = NULL;
 	int result = 0;
 	int i = 0;
diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index 59ffe0c..a312485 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -46,6 +46,7 @@
 #include "ivi-layout-export.h"
 #include "ivi-layout-shell.h"
 #include "shared/helpers.h"
+#include "weston.h"
 
 /* Representation of ivi_surface protocol object. */
 struct ivi_shell_surface
@@ -416,7 +417,7 @@ ivi_shell_setting_create(struct ivi_shell_setting *dest,
 			 int *argc, char *argv[])
 {
 	int result = 0;
-	struct weston_config *config = compositor->config;
+	struct weston_config *config = weston_get_config(compositor);
 	struct weston_config_section *section;
 
 	const struct weston_option ivi_shell_options[] = {
diff --git a/src/cms-static.c b/src/cms-static.c
index 0273ee3..1feb902 100644
--- a/src/cms-static.c
+++ b/src/cms-static.c
@@ -31,6 +31,7 @@
 #include "compositor.h"
 #include "cms-helper.h"
 #include "shared/helpers.h"
+#include "weston.h"
 
 struct cms_static {
 	struct weston_compositor	*ec;
@@ -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(weston_get_config(cms->ec),
 				      "output", "name", o->name);
 	if (s == NULL)
 		return;
diff --git a/src/compositor.h b/src/compositor.h
index 4b006af..4600ae3 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -726,7 +726,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;
diff --git a/src/libinput-device.c b/src/libinput-device.c
index c5d3fd1..3443666 100644
--- a/src/libinput-device.c
+++ b/src/libinput-device.c
@@ -39,6 +39,7 @@
 #include "compositor.h"
 #include "libinput-device.h"
 #include "shared/helpers.h"
+#include "weston.h"
 
 void
 evdev_led_update(struct evdev_device *device, enum weston_led weston_leds)
@@ -528,10 +529,11 @@ configure_device(struct evdev_device *device)
 {
 	struct weston_compositor *compositor = device->seat->compositor;
 	struct weston_config_section *s;
+	struct weston_config *config = weston_get_config(compositor);
 	int enable_tap;
 	int enable_tap_default;
 
-	s = weston_config_get_section(compositor->config,
+	s = weston_config_get_section(config,
 				      "libinput", NULL, NULL);
 
 	if (libinput_device_config_tap_get_finger_count(device->device) > 0) {
diff --git a/src/main.c b/src/main.c
index 91b951c..81802f6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -331,6 +331,12 @@ log_uname(void)
 						usys.version, usys.machine);
 }
 
+WL_EXPORT struct weston_config *
+weston_get_config(struct weston_compositor *compositor)
+{
+	return weston_compositor_get_user_data(compositor);
+}
+
 static const char xdg_error_message[] =
 	"fatal: environment variable XDG_RUNTIME_DIR is not set.\n";
 
@@ -846,7 +852,7 @@ drm_configure_output(struct weston_compositor *c,
 		     const char *name,
 		     struct weston_drm_backend_output_config *config)
 {
-	struct weston_config *wc = weston_compositor_get_user_data(c);
+	struct weston_config *wc = weston_get_config(c);
 	struct weston_config_section *section;
 	char *s;
 	int scale;
@@ -1515,7 +1521,6 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
-	ec->config = config;
 	if (weston_compositor_init_config(ec, config) < 0)
 		goto out;
 
diff --git a/src/text-backend.c b/src/text-backend.c
index 743cbc4..a2f290f 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -1026,11 +1026,12 @@ handle_seat_created(struct wl_listener *listener, void *data)
 static void
 text_backend_configuration(struct text_backend *text_backend)
 {
+	struct weston_config *config = weston_get_config(text_backend->compositor);
 	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());
diff --git a/src/weston.h b/src/weston.h
index f2bc1ac..cd58020 100644
--- a/src/weston.h
+++ b/src/weston.h
@@ -57,6 +57,9 @@ weston_client_start(struct weston_compositor *compositor, const char *path);
 void
 weston_watch_process(struct weston_process *process);
 
+struct weston_config *
+weston_get_config(struct weston_compositor *compositor);
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/xwayland/launcher.c b/xwayland/launcher.c
index db5e1d0..ae9c30e 100644
--- a/xwayland/launcher.c
+++ b/xwayland/launcher.c
@@ -37,7 +37,7 @@
 
 #include "xwayland.h"
 #include "shared/helpers.h"
-
+#include "weston.h"
 
 static int
 handle_sigusr1(int signal_number, void *data)
@@ -60,6 +60,7 @@ weston_xserver_handle_event(int listen_fd, uint32_t mask, void *data)
 	char display[8], s[8], abstract_fd[8], unix_fd[8], wm_fd[8];
 	int sv[2], wm[2], fd;
 	char *xserver = NULL;
+	struct weston_config *config = weston_get_config(wxs->compositor);
 	struct weston_config_section *section;
 
 	if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
@@ -98,7 +99,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(config,
 						    "xwayland", NULL, NULL);
 		weston_config_section_get_string(section, "path",
 						 &xserver, XSERVER_PATH);
-- 
2.8.3



More information about the wayland-devel mailing list