[PATCH weston v6 72/73] weston: use wet.compositor consistently in main()

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 16 14:57:57 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>
---
 compositor/main.c | 50 ++++++++++++++++++++++++--------------------------
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index bbd00bb1..e549801e 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1804,7 +1804,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;
@@ -1827,7 +1826,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;
 
@@ -1900,8 +1899,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);
 
@@ -1922,28 +1921,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)
@@ -1951,11 +1949,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) {
@@ -1984,28 +1982,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);
 
@@ -2021,7 +2019,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);
 
@@ -2031,13 +2029,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.13.6



More information about the wayland-devel mailing list