[PATCH weston v9 6/9] weston: store weston_compositor in wet_compositor

Pekka Paalanen ppaalanen at gmail.com
Thu Apr 19 12:09:16 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>
Acked-by: Derek Foreman <derekf at osg.samsung.com>
---
 compositor/main.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index f72d3ea1..42b8e3fe 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;
@@ -1088,9 +1089,8 @@ 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;
 
@@ -1100,7 +1100,8 @@ simple_head_enable(struct weston_compositor *compositor, struct weston_head *hea
 	if (weston_head_get_output(head))
 		return;
 
-	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));
@@ -1157,18 +1158,19 @@ static void
 simple_heads_changed(struct wl_listener *listener, void *arg)
 {
 	struct weston_compositor *compositor = arg;
+	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) {
@@ -1925,6 +1927,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.16.1



More information about the wayland-devel mailing list