[PATCH weston v9 7/9] weston: use wet.compositor consistently in main()

Pekka Paalanen ppaalanen at gmail.com
Thu Apr 19 12:09:17 UTC 2018


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Rename user_data to wet, because it is called wet everywhere else.

Drop the local variable ec, because that is available as wet.compositor.

This models a little better that wet_compositor owns weston_compositor,
and not the other way around.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Acked-by: Derek Foreman <derekf at osg.samsung.com>
---
 compositor/main.c | 50 ++++++++++++++++++++++++--------------------------
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 42b8e3fe..85c4d338 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1808,7 +1808,6 @@ int main(int argc, char *argv[])
 	int ret = EXIT_FAILURE;
 	char *cmdline;
 	struct wl_display *display;
-	struct weston_compositor *ec;
 	struct wl_event_source *signals[4];
 	struct wl_event_loop *loop;
 	int i, fd;
@@ -1831,7 +1830,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 = { 0 };
+	struct wet_compositor wet = { 0 };
 	int require_input;
 	int32_t wait_for_debugger = 0;
 
@@ -1904,8 +1903,8 @@ int main(int argc, char *argv[])
 
 	if (load_configuration(&config, noconfig, config_file) < 0)
 		goto out_signals;
-	user_data.config = config;
-	user_data.parsed_options = NULL;
+	wet.config = config;
+	wet.parsed_options = NULL;
 
 	section = weston_config_get_section(config, "core", NULL, NULL);
 
@@ -1926,28 +1925,27 @@ int main(int argc, char *argv[])
 			backend = weston_choose_default_backend();
 	}
 
-	ec = weston_compositor_create(display, &user_data);
-	user_data.compositor = ec;
-	if (ec == NULL) {
+	wet.compositor = weston_compositor_create(display, &wet);
+	if (wet.compositor == NULL) {
 		weston_log("fatal: failed to create compositor\n");
 		goto out;
 	}
-	segv_compositor = ec;
+	segv_compositor = wet.compositor;
 
-	if (weston_compositor_init_config(ec, config) < 0)
+	if (weston_compositor_init_config(wet.compositor, config) < 0)
 		goto out;
 
 	weston_config_section_get_bool(section, "require-input",
 				       &require_input, true);
-	ec->require_input = require_input;
+	wet.compositor->require_input = require_input;
 
-	if (load_backend(ec, backend, &argc, argv, config) < 0) {
+	if (load_backend(wet.compositor, backend, &argc, argv, config) < 0) {
 		weston_log("fatal: failed to create compositor backend\n");
 		goto out;
 	}
 
-	weston_compositor_flush_heads_changed(ec);
-	if (user_data.init_failed)
+	weston_compositor_flush_heads_changed(wet.compositor);
+	if (wet.init_failed)
 		goto out;
 
 	if (idle_time < 0)
@@ -1955,11 +1953,11 @@ int main(int argc, char *argv[])
 	if (idle_time < 0)
 		idle_time = 300; /* default idle timeout, in seconds */
 
-	ec->idle_time = idle_time;
-	ec->default_pointer_grab = NULL;
-	ec->exit = handle_exit;
+	wet.compositor->idle_time = idle_time;
+	wet.compositor->default_pointer_grab = NULL;
+	wet.compositor->exit = handle_exit;
 
-	weston_compositor_log_capabilities(ec);
+	weston_compositor_log_capabilities(wet.compositor);
 
 	server_socket = getenv("WAYLAND_SERVER_SOCKET");
 	if (server_socket) {
@@ -1988,28 +1986,28 @@ int main(int argc, char *argv[])
 		weston_config_section_get_string(section, "shell", &shell,
 						 "desktop-shell.so");
 
-	if (wet_load_shell(ec, shell, &argc, argv) < 0)
+	if (wet_load_shell(wet.compositor, shell, &argc, argv) < 0)
 		goto out;
 
 	weston_config_section_get_string(section, "modules", &modules, "");
-	if (load_modules(ec, modules, &argc, argv, &xwayland) < 0)
+	if (load_modules(wet.compositor, modules, &argc, argv, &xwayland) < 0)
 		goto out;
 
-	if (load_modules(ec, option_modules, &argc, argv, &xwayland) < 0)
+	if (load_modules(wet.compositor, option_modules, &argc, argv, &xwayland) < 0)
 		goto out;
 
 	if (!xwayland)
 		weston_config_section_get_bool(section, "xwayland", &xwayland,
 					       false);
 	if (xwayland) {
-		if (wet_load_xwayland(ec) < 0)
+		if (wet_load_xwayland(wet.compositor) < 0)
 			goto out;
 	}
 
 	section = weston_config_get_section(config, "keyboard", NULL, NULL);
 	weston_config_section_get_bool(section, "numlock-on", &numlock_on, 0);
 	if (numlock_on) {
-		wl_list_for_each(seat, &ec->seat_list, link) {
+		wl_list_for_each(seat, &wet.compositor->seat_list, link) {
 			struct weston_keyboard *keyboard =
 				weston_seat_get_keyboard(seat);
 
@@ -2025,7 +2023,7 @@ int main(int argc, char *argv[])
 	if (argc > 1)
 		goto out;
 
-	weston_compositor_wake(ec);
+	weston_compositor_wake(wet.compositor);
 
 	wl_display_run(display);
 
@@ -2035,13 +2033,13 @@ int main(int argc, char *argv[])
 	* that want to indicate failure status to
 	* testing infrastructure above
 	*/
-	ret = ec->exit_code;
+	ret = wet.compositor->exit_code;
 
 out:
 	/* free(NULL) is valid, and it won't be NULL if it's used */
-	free(user_data.parsed_options);
+	free(wet.parsed_options);
 
-	weston_compositor_destroy(ec);
+	weston_compositor_destroy(wet.compositor);
 
 out_signals:
 	for (i = ARRAY_LENGTH(signals) - 1; i >= 0; i--)
-- 
2.16.1



More information about the wayland-devel mailing list