[PATCH] compositor: Extend compositor user data

Armin Krezović krezovic.armin at gmail.com
Mon Aug 1 12:09:59 UTC 2016


This patch makes the compositor user data a structure
which can be expanded with new fields when necessary.

Signed-off-by: Armin Krezović <krezovic.armin at gmail.com>
---
 compositor/main.c   | 14 ++++++++++++--
 compositor/weston.h |  7 +++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 99cb868..bb7d8ad 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -414,10 +414,18 @@ log_uname(void)
 						usys.version, usys.machine);
 }
 
+WL_EXPORT struct wet_compositor *
+to_wet_compositor(struct weston_compositor *compositor)
+{
+	return weston_compositor_get_user_data(compositor);
+}
+
 WL_EXPORT struct weston_config *
 wet_get_config(struct weston_compositor *compositor)
 {
-	return weston_compositor_get_user_data(compositor);
+	struct wet_compositor *d = to_wet_compositor(compositor);
+
+	return d->config;
 }
 
 static const char xdg_error_message[] =
@@ -1581,6 +1589,7 @@ int main(int argc, char *argv[])
 	struct wl_client *primary_client;
 	struct wl_listener primary_client_destroyed;
 	struct weston_seat *seat;
+	struct wet_compositor user_data;
 
 	const struct weston_option core_options[] = {
 		{ WESTON_OPTION_STRING, "backend", 'B', &backend },
@@ -1644,6 +1653,7 @@ int main(int argc, char *argv[])
 
 	if (load_configuration(&config, noconfig, config_file) < 0)
 		goto out_signals;
+	user_data.config = config;
 
 	section = weston_config_get_section(config, "core", NULL, NULL);
 
@@ -1654,7 +1664,7 @@ int main(int argc, char *argv[])
 			backend = weston_choose_default_backend();
 	}
 
-	ec = weston_compositor_create(display, config);
+	ec = weston_compositor_create(display, &user_data);
 	if (ec == NULL) {
 		weston_log("fatal: failed to create compositor\n");
 		goto out;
diff --git a/compositor/weston.h b/compositor/weston.h
index bff5cc1..7fd8d8f 100644
--- a/compositor/weston.h
+++ b/compositor/weston.h
@@ -32,6 +32,10 @@ extern "C" {
 
 #include <compositor.h>
 
+struct wet_compositor {
+	struct weston_config *config;
+};
+
 void
 screenshooter_create(struct weston_compositor *ec);
 
@@ -57,6 +61,9 @@ weston_client_start(struct weston_compositor *compositor, const char *path);
 void
 weston_watch_process(struct weston_process *process);
 
+struct wet_compositor *
+to_wet_compositor(struct weston_compositor *compositor);
+
 struct weston_config *
 wet_get_config(struct weston_compositor *compositor);
 
-- 
2.9.2



More information about the wayland-devel mailing list