[PATCH weston v3 06/36] libweston: refactor weston_mode_switch_finish

Pekka Paalanen ppaalanen at gmail.com
Tue Oct 31 11:48:16 UTC 2017


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

Split out a new function. This is a pure refactoring, no change in
behaviour.

This helps a following patch that adds a loop over output->head_list.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 libweston/compositor.c | 57 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 36 insertions(+), 21 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index c3c7e27c..d96c96d4 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -76,15 +76,45 @@ weston_output_transform_scale_init(struct weston_output *output,
 static void
 weston_compositor_build_view_list(struct weston_compositor *compositor);
 
-static void weston_mode_switch_finish(struct weston_output *output,
-				      int mode_changed,
-				      int scale_changed)
+/** Send wl_output events for mode and scale changes
+ *
+ * \param head Send on all resources bound to this head.
+ * \param mode_changed If true, send the current mode.
+ * \param scale_changed If true, send the current scale.
+ */
+static void
+weston_mode_switch_send_events(struct weston_head *head,
+			       bool mode_changed, bool scale_changed)
+{
+	struct weston_output *output = head->output;
+	struct wl_resource *resource;
+	int version;
+
+	wl_resource_for_each(resource, &head->resource_list) {
+		if (mode_changed) {
+			wl_output_send_mode(resource,
+					    output->current_mode->flags,
+					    output->current_mode->width,
+					    output->current_mode->height,
+					    output->current_mode->refresh);
+		}
+
+		version = wl_resource_get_version(resource);
+		if (version >= WL_OUTPUT_SCALE_SINCE_VERSION && scale_changed)
+			wl_output_send_scale(resource, output->current_scale);
+
+		if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
+			wl_output_send_done(resource);
+	}
+}
+
+static void
+weston_mode_switch_finish(struct weston_output *output,
+			  int mode_changed, int scale_changed)
 {
 	struct weston_seat *seat;
 	struct weston_head *head;
-	struct wl_resource *resource;
 	pixman_region32_t old_output_region;
-	int version;
 
 	pixman_region32_init(&old_output_region);
 	pixman_region32_copy(&old_output_region, &output->region);
@@ -133,22 +163,7 @@ static void weston_mode_switch_finish(struct weston_output *output,
 	head = &output->head;
 
 	/* notify clients of the changes */
-	wl_resource_for_each(resource, &head->resource_list) {
-		if (mode_changed) {
-			wl_output_send_mode(resource,
-					    output->current_mode->flags,
-					    output->current_mode->width,
-					    output->current_mode->height,
-					    output->current_mode->refresh);
-		}
-
-		version = wl_resource_get_version(resource);
-		if (version >= WL_OUTPUT_SCALE_SINCE_VERSION && scale_changed)
-			wl_output_send_scale(resource, output->current_scale);
-
-		if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
-			wl_output_send_done(resource);
-	}
+	weston_mode_switch_send_events(head, mode_changed, scale_changed);
 }
 
 
-- 
2.13.6



More information about the wayland-devel mailing list