[PATCH weston 7/9] Pass config_file through to weston_compositor_init

Daniel Stone daniel at fooishbar.org
Fri Jun 1 04:14:04 PDT 2012


This allows us to do config parsing there.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 src/compositor-android.c |   11 +++++++----
 src/compositor-drm.c     |   11 +++++++----
 src/compositor-wayland.c |   10 ++++++----
 src/compositor-x11.c     |   10 ++++++----
 src/compositor.c         |   10 +++++-----
 src/compositor.h         |    5 +++--
 6 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/src/compositor-android.c b/src/compositor-android.c
index 91bbf74..3343481 100644
--- a/src/compositor-android.c
+++ b/src/compositor-android.c
@@ -403,7 +403,8 @@ android_compositor_destroy(struct weston_compositor *base)
 }
 
 static struct weston_compositor *
-android_compositor_create(struct wl_display *display, int argc, char *argv[])
+android_compositor_create(struct wl_display *display, int argc, char *argv[],
+			  const char *config_file)
 {
 	struct android_compositor *compositor;
 	struct android_output *output;
@@ -425,7 +426,8 @@ android_compositor_create(struct wl_display *display, int argc, char *argv[])
 	if (android_init_egl(compositor, output) < 0)
 		return NULL;
 
-	if (weston_compositor_init(&compositor->base, display, argc, argv) < 0)
+	if (weston_compositor_init(&compositor->base, display, argc, argv,
+				   config_file) < 0)
 		return NULL;
 
 	android_compositor_add_output(compositor, output);
@@ -438,7 +440,8 @@ android_compositor_create(struct wl_display *display, int argc, char *argv[])
 }
 
 WL_EXPORT struct weston_compositor *
-backend_init(struct wl_display *display, int argc, char *argv[])
+backend_init(struct wl_display *display, int argc, char *argv[],
+	     const char *config_file)
 {
-	return android_compositor_create(display, argc, argv);
+	return android_compositor_create(display, argc, argv, config_file);
 }
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 5217c0e..500ea7c 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1739,7 +1739,7 @@ static const char default_seat[] = "seat0";
 static struct weston_compositor *
 drm_compositor_create(struct wl_display *display,
 		      int connector, const char *seat, int tty,
-		      int argc, char *argv[])
+		      int argc, char *argv[], const char *config_file)
 {
 	struct drm_compositor *ec;
 	struct udev_enumerate *e;
@@ -1805,7 +1805,8 @@ drm_compositor_create(struct wl_display *display,
 	ec->prev_state = WESTON_COMPOSITOR_ACTIVE;
 
 	/* Can't init base class until we have a current egl context */
-	if (weston_compositor_init(&ec->base, display, argc, argv) < 0)
+	if (weston_compositor_init(&ec->base, display, argc, argv,
+				   config_file) < 0)
 		return NULL;
 
 	for (key = KEY_F1; key < KEY_F9; key++)
@@ -1853,7 +1854,8 @@ drm_compositor_create(struct wl_display *display,
 }
 
 WL_EXPORT struct weston_compositor *
-backend_init(struct wl_display *display, int argc, char *argv[])
+backend_init(struct wl_display *display, int argc, char *argv[],
+	     const char *config_file)
 {
 	int connector = 0, tty = 0;
 	const char *seat = default_seat;
@@ -1866,5 +1868,6 @@ backend_init(struct wl_display *display, int argc, char *argv[])
 
 	parse_options(drm_options, ARRAY_LENGTH(drm_options), argc, argv);
 
-	return drm_compositor_create(display, connector, seat, tty, argc, argv);
+	return drm_compositor_create(display, connector, seat, tty, argc, argv,
+				     config_file);
 }
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index cae7ba3..cd0e382 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -756,7 +756,7 @@ wayland_destroy(struct weston_compositor *ec)
 static struct weston_compositor *
 wayland_compositor_create(struct wl_display *display,
 			  int width, int height, const char *display_name,
-			  int argc, char *argv[])
+			  int argc, char *argv[], const char *config_file)
 {
 	struct wayland_compositor *c;
 	struct wl_event_loop *loop;
@@ -790,7 +790,8 @@ wayland_compositor_create(struct wl_display *display,
 	c->base.destroy = wayland_destroy;
 
 	/* Can't init base class until we have a current egl context */
-	if (weston_compositor_init(&c->base, display, argc, argv) < 0)
+	if (weston_compositor_init(&c->base, display, argc, argv,
+				   config_file) < 0)
 		return NULL;
 
 	if (wayland_input_create(c) < 0)
@@ -813,7 +814,8 @@ wayland_compositor_create(struct wl_display *display,
 }
 
 WL_EXPORT struct weston_compositor *
-backend_init(struct wl_display *display, int argc, char *argv[])
+backend_init(struct wl_display *display, int argc, char *argv[],
+	     const char *config_file)
 {
 	int width = 1024, height = 640;
 	char *display_name = NULL;
@@ -828,5 +830,5 @@ backend_init(struct wl_display *display, int argc, char *argv[])
 		      ARRAY_LENGTH(wayland_options), argc, argv);
 
 	return wayland_compositor_create(display, width, height, display_name,
-					 argc, argv);
+					 argc, argv, config_file);
 }
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index ac6dce4..d23553e 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -848,7 +848,7 @@ x11_destroy(struct weston_compositor *ec)
 static struct weston_compositor *
 x11_compositor_create(struct wl_display *display,
 		      int width, int height, int count, int fullscreen,
-		      int argc, char *argv[])
+		      int argc, char *argv[], const char *config_file)
 {
 	struct x11_compositor *c;
 	xcb_screen_iterator_t s;
@@ -883,7 +883,8 @@ x11_compositor_create(struct wl_display *display,
 	c->base.destroy = x11_destroy;
 
 	/* Can't init base class until we have a current egl context */
-	if (weston_compositor_init(&c->base, display, argc, argv) < 0)
+	if (weston_compositor_init(&c->base, display, argc, argv,
+				   config_file) < 0)
 		return NULL;
 
 	for (i = 0, x = 0; i < count; i++) {
@@ -907,7 +908,8 @@ x11_compositor_create(struct wl_display *display,
 }
 
 WL_EXPORT struct weston_compositor *
-backend_init(struct wl_display *display, int argc, char *argv[])
+backend_init(struct wl_display *display, int argc, char *argv[],
+	     const char *config_file)
 {
 	int width = 1024, height = 640, fullscreen = 0, count = 1;
 
@@ -922,5 +924,5 @@ backend_init(struct wl_display *display, int argc, char *argv[])
 
 	return x11_compositor_create(display,
 				     width, height, count, fullscreen,
-				     argc, argv);
+				     argc, argv, config_file);
 }
diff --git a/src/compositor.c b/src/compositor.c
index f9c9b2c..ef3802d 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2841,7 +2841,8 @@ WL_EXPORT int
 weston_compositor_init(struct weston_compositor *ec,
 		       struct wl_display *display,
 		       int argc,
-		       char *argv[])
+		       char *argv[],
+		       const char *config_file)
 {
 	struct wl_event_loop *loop;
 	const char *extensions;
@@ -3041,7 +3042,7 @@ int main(int argc, char *argv[])
 	int (*module_init)(struct weston_compositor *ec);
 	struct weston_compositor
 		*(*backend_init)(struct wl_display *display,
-				 int argc, char *argv[]);
+				 int argc, char *argv[], const char *config_file);
 	int i;
 	char *backend = NULL;
 	char *shell = NULL;
@@ -3116,13 +3117,12 @@ int main(int argc, char *argv[])
 
 	config_file = config_file_path("weston.ini");
 	parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell);
-	free(config_file);
 
 	backend_init = load_module(backend, "backend_init", &backend_module);
 	if (!backend_init)
 		exit(EXIT_FAILURE);
 
-	ec = backend_init(display, argc, argv);
+	ec = backend_init(display, argc, argv, config_file);
 	if (ec == NULL) {
 		fprintf(stderr, "failed to create compositor\n");
 		exit(EXIT_FAILURE);
@@ -3133,7 +3133,7 @@ int main(int argc, char *argv[])
 	if (argv[1])
 		exit(EXIT_FAILURE);
 
-	weston_compositor_xkb_init(ec, &xkb_names);
+	free(config_file);
 
 	ec->option_idle_time = idle_time;
 	ec->idle_time = idle_time;
diff --git a/src/compositor.h b/src/compositor.h
index e00dfe3..23beb5f 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -624,7 +624,7 @@ weston_compositor_get_time(void);
 
 int
 weston_compositor_init(struct weston_compositor *ec, struct wl_display *display,
-		       int argc, char *argv[]);
+		       int argc, char *argv[], const char *config_file);
 void
 weston_compositor_shutdown(struct weston_compositor *ec);
 void
@@ -722,7 +722,8 @@ void
 weston_surface_destroy(struct weston_surface *surface);
 
 struct weston_compositor *
-backend_init(struct wl_display *display, int argc, char *argv[]);
+backend_init(struct wl_display *display, int argc, char *argv[],
+	     const char *config_file);
 
 int
 weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode);
-- 
1.7.10



More information about the wayland-devel mailing list