[PATCH weston 1/4] Add weston_compositor_pre_init

Daniel Stone daniel at fooishbar.org
Mon Jun 18 11:10:30 PDT 2012


Split off list initialisation from weston_compositor_init.  If we call
this from weston_compositor_init, then we can make it safe to call
weston_compositor_shutdown during init.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 src/compositor-android.c |    2 ++
 src/compositor-drm.c     |    2 ++
 src/compositor-openwfd.c |    2 ++
 src/compositor-wayland.c |    2 ++
 src/compositor-x11.c     |    2 ++
 src/compositor.c         |   23 ++++++++++++++++-------
 src/compositor.h         |    2 ++
 7 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/src/compositor-android.c b/src/compositor-android.c
index 06c8517..bc47b2d 100644
--- a/src/compositor-android.c
+++ b/src/compositor-android.c
@@ -414,6 +414,8 @@ android_compositor_create(struct wl_display *display, int argc, char *argv[],
 	if (compositor == NULL)
 		return NULL;
 
+	weston_compositor_pre_init(&compositor->base);
+
 	compositor->base.destroy = android_compositor_destroy;
 
 	compositor->base.focus = 1;
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 45ef6ef..c91b2be 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1763,6 +1763,8 @@ drm_compositor_create(struct wl_display *display,
 		return NULL;
 
 	memset(ec, 0, sizeof *ec);
+	weston_compositor_pre_init(&ec->base);
+
 	ec->udev = udev_new();
 	if (ec->udev == NULL) {
 		weston_log("failed to initialize udev context\n");
diff --git a/src/compositor-openwfd.c b/src/compositor-openwfd.c
index aac8064..e4debc1 100644
--- a/src/compositor-openwfd.c
+++ b/src/compositor-openwfd.c
@@ -611,6 +611,8 @@ wfd_compositor_create(struct wl_display *display,
 
 	memset(ec, 0, sizeof *ec);
 
+	weston_compositor_pre_init(&ec->base);
+
 	gettimeofday(&tv, NULL);
 	ec->start_time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
 
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index fc1917d..b1971a9 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -838,6 +838,8 @@ wayland_compositor_create(struct wl_display *display,
 
 	memset(c, 0, sizeof *c);
 
+	weston_compositor_pre_init(&c->base);
+
 	c->parent.display = wl_display_connect(display_name);
 
 	if (c->parent.display == NULL) {
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 44a48b0..d32af90 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -876,6 +876,8 @@ x11_compositor_create(struct wl_display *display,
 
 	memset(c, 0, sizeof *c);
 
+	weston_compositor_pre_init(&c->base);
+
 	c->dpy = XOpenDisplay(NULL);
 	if (c->dpy == NULL)
 		return NULL;
diff --git a/src/compositor.c b/src/compositor.c
index d40a878..224d9ff 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2935,6 +2935,22 @@ log_egl_gl_info(EGLDisplay egldpy)
 	log_extensions("GL extensions", str ? str : "(null)");
 }
 
+WL_EXPORT void
+weston_compositor_pre_init(struct weston_compositor *ec)
+{
+	wl_list_init(&ec->surface_list);
+	wl_list_init(&ec->layer_list);
+	wl_list_init(&ec->seat_list);
+	wl_list_init(&ec->output_list);
+
+	wl_list_init(&ec->key_binding_list);
+	wl_list_init(&ec->button_binding_list);
+	wl_list_init(&ec->axis_binding_list);
+
+	wl_array_init(&ec->vertices);
+	wl_array_init(&ec->indices);
+}
+
 WL_EXPORT int
 weston_compositor_init(struct weston_compositor *ec,
 		       struct wl_display *display,
@@ -3019,13 +3035,6 @@ weston_compositor_init(struct weston_compositor *ec,
 	if (ec->has_bind_display)
 		ec->bind_display(ec->display, ec->wl_display);
 
-	wl_list_init(&ec->surface_list);
-	wl_list_init(&ec->layer_list);
-	wl_list_init(&ec->seat_list);
-	wl_list_init(&ec->output_list);
-	wl_list_init(&ec->key_binding_list);
-	wl_list_init(&ec->button_binding_list);
-	wl_list_init(&ec->axis_binding_list);
 	weston_spring_init(&ec->fade.spring, 30.0, 1.0, 1.0);
 	ec->fade.animation.frame = fade_frame;
 	wl_list_init(&ec->fade.animation.link);
diff --git a/src/compositor.h b/src/compositor.h
index df100d5..4f1d045 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -633,6 +633,8 @@ weston_buffer_post_release(struct wl_buffer *buffer);
 uint32_t
 weston_compositor_get_time(void);
 
+void
+weston_compositor_pre_init(struct weston_compositor *ec);
 int
 weston_compositor_init(struct weston_compositor *ec, struct wl_display *display,
 		       int argc, char *argv[], const char *config_file);
-- 
1.7.10



More information about the wayland-devel mailing list