[PATCH weston 1/3] compositor: Add visibility state to surfaces

Jonas Ådahl jadahl at gmail.com
Wed Jun 6 02:36:08 PDT 2012


When a surface becomes invisible frame callbacks will be queued until
the surface is shown.

Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
 src/compositor.c |   28 +++++++++++++++++++++++++---
 src/compositor.h |    6 ++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 7cc176c..139c379 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -233,6 +233,7 @@ weston_surface_create(struct weston_compositor *compositor)
 	surface->opaque_rect[2] = 0.0;
 	surface->opaque_rect[3] = 0.0;
 	surface->pitch = 1;
+	surface->visible = true;
 
 	surface->buffer = NULL;
 	surface->output = NULL;
@@ -1115,7 +1116,10 @@ WL_EXPORT void
 weston_layer_init(struct weston_layer *layer, struct wl_list *below)
 {
 	wl_list_init(&layer->surface_list);
-	wl_list_insert(below, &layer->link);
+	if (below != NULL)
+		wl_list_insert(below, &layer->link);
+	else
+		wl_list_init(&layer->link);
 }
 
 WL_EXPORT void
@@ -1175,6 +1179,24 @@ weston_compositor_fade(struct weston_compositor *compositor, float tint)
 			       &compositor->fade.animation.link);
 }
 
+WL_EXPORT void
+weston_surface_show(struct weston_surface *es)
+{
+	es->visible = true;
+
+	if (!wl_list_empty(&es->frame_callback_list)) {
+		wl_list_insert_list(es->output->frame_callback_list.prev,
+				    &es->frame_callback_list);
+		wl_list_init(&es->frame_callback_list);
+	}
+}
+
+WL_EXPORT void
+weston_surface_hide(struct weston_surface *es)
+{
+	es->visible = false;
+}
+
 static void
 surface_destroy(struct wl_client *client, struct wl_resource *resource)
 {
@@ -1255,7 +1277,7 @@ weston_surface_assign_output(struct weston_surface *es)
 	es->output = new_output;
 	weston_surface_update_output_mask(es, mask);
 
-	if (!wl_list_empty(&es->frame_callback_list)) {
+	if (es->visible && !wl_list_empty(&es->frame_callback_list)) {
 		wl_list_insert_list(new_output->frame_callback_list.prev,
 				    &es->frame_callback_list);
 		wl_list_init(&es->frame_callback_list);
@@ -1349,7 +1371,7 @@ surface_frame(struct wl_client *client,
 
 	wl_client_add_resource(client, &cb->resource);
 
-	if (es->output) {
+	if (es->output && es->visible) {
 		wl_list_insert(es->output->frame_callback_list.prev,
 			       &cb->link);
 	} else {
diff --git a/src/compositor.h b/src/compositor.h
index 2d52048..1f1095b 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -24,6 +24,7 @@
 #ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
 #define _WAYLAND_SYSTEM_COMPOSITOR_H_
 
+#include <stdbool.h>
 #include <pixman.h>
 #include <xkbcommon/xkbcommon.h>
 #include <wayland-server.h>
@@ -383,6 +384,7 @@ struct weston_surface {
 	GLfloat opaque_rect[4];
 	GLfloat alpha;
 	int blend;
+	bool visible;
 
 	/* Surface geometry state, mutable.
 	 * If you change anything, set dirty = 1.
@@ -521,6 +523,10 @@ weston_compositor_schedule_repaint(struct weston_compositor *compositor);
 void
 weston_compositor_fade(struct weston_compositor *compositor, float tint);
 void
+weston_surface_show(struct weston_surface *es);
+void
+weston_surface_hide(struct weston_surface *es);
+void
 weston_compositor_damage_all(struct weston_compositor *compositor);
 void
 weston_compositor_unlock(struct weston_compositor *compositor);
-- 
1.7.9.5



More information about the wayland-devel mailing list