[PATCH weston v6 71/73] weston: store weston_compositor in wet_compositor

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 16 14:57:56 UTC 2018


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

This makes it easier to just pass wet_compositor around and take the
weston_compositor from it.

It feels weird to go from weston_compositor to wet_compositor all the
time in internal functions. It's necessary in callbacks that cannot
carry wet_compositor, but otherwise it is awkward.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 compositor/main.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index c9554625..bbd00bb1 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -76,6 +76,7 @@ struct wet_head_tracker {
 };
 
 struct wet_compositor {
+	struct weston_compositor *compositor;
 	struct weston_config *config;
 	struct wet_output_config *parsed_options;
 	bool drm_use_current_mode;
@@ -1085,13 +1086,13 @@ wet_head_tracker_create(struct wet_compositor *compositor,
 }
 
 static void
-simple_head_enable(struct weston_compositor *compositor, struct weston_head *head)
+simple_head_enable(struct wet_compositor *wet, struct weston_head *head)
 {
-	struct wet_compositor *wet = to_wet_compositor(compositor);
 	struct weston_output *output;
 	int ret = 0;
 
-	output = weston_compositor_create_output_with_head(compositor, head);
+	output = weston_compositor_create_output_with_head(wet->compositor,
+							   head);
 	if (!output) {
 		weston_log("Could not create an output for head \"%s\".\n",
 			   weston_head_get_name(head));
@@ -1147,18 +1148,19 @@ simple_head_disable(struct weston_head *head)
 static void
 simple_heads_changed(struct weston_compositor *compositor)
 {
+	struct wet_compositor *wet = to_wet_compositor(compositor);
 	struct weston_head *head = NULL;
 	bool connected;
 	bool enabled;
 	bool changed;
 
-	while ((head = weston_compositor_iterate_heads(compositor, head))) {
+	while ((head = weston_compositor_iterate_heads(wet->compositor, head))) {
 		connected = weston_head_is_connected(head);
 		enabled = weston_head_is_enabled(head);
 		changed = weston_head_is_device_changed(head);
 
 		if (connected && !enabled) {
-			simple_head_enable(compositor, head);
+			simple_head_enable(wet, head);
 		} else if (!connected && enabled) {
 			simple_head_disable(head);
 		} else if (enabled && changed) {
@@ -1921,6 +1923,7 @@ int main(int argc, char *argv[])
 	}
 
 	ec = weston_compositor_create(display, &user_data);
+	user_data.compositor = ec;
 	if (ec == NULL) {
 		weston_log("fatal: failed to create compositor\n");
 		goto out;
-- 
2.13.6



More information about the wayland-devel mailing list