window: add a note about freeing shm buffers

After a client has been double-buffering, and then switches to
single-buffering, it should release the 2nd buffer. That never happens
in practice here, so just add a comment and a check in case it ever
occurs in the future.

If we implemented the releasing now, it would be difficult to test.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
diff --git a/clients/window.c b/clients/window.c
index c7767ae..29f6c87 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -833,6 +833,14 @@
 	struct shm_surface_leaf *leaf = data;
 
 	leaf->busy = 0;
+
+	/* If both leaves are now free, we should call
+	 * shm_surface_leaf_release(shm_surface::leaf[1]).
+	 * However, none of Weston's backends switch dynamically
+	 * between early buffer release and requiring double-buffering,
+	 * so if both leaves are free, we never used the second
+	 * leaf to begin with.
+	 */
 }
 
 static const struct wl_buffer_listener shm_surface_buffer_listener = {
@@ -851,6 +859,13 @@
 	surface->dx = dx;
 	surface->dy = dy;
 
+	/* See shm_surface_buffer_release() */
+	if (!surface->leaf[0].busy && !surface->leaf[1].busy &&
+	    surface->leaf[1].cairo_surface) {
+		fprintf(stderr, "window.c:%s: TODO: release leaf[1]\n",
+			__func__);
+	}
+
 	/* pick a free buffer from the two */
 	if (!surface->leaf[0].busy)
 		leaf = &surface->leaf[0];