From 32a0f88b04c63924eb6428d3847d9fb9aec179ae Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 2 May 2013 17:56:38 +0100 Subject: [PATCH] cogland: Correctly handle commits without attaching a new buffer Previously if a client sent a commit message without attaching a new buffer then it would end up detaching the existing buffer because surface->pending.buffer would be NULL. This patch makes it explicitly track when an attach is sent for a commit and so that it can avoid making any changes otherwise. This fixes cases where GTK apps would send a damage event without a new buffer. Reviewed-by: Robert Bragg (cherry picked from commit aa412b9c709120bd8d88a014010c448f3b9fcfb7) --- examples/cogland.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/cogland.c b/examples/cogland.c index b5778fce6..029f39b06 100644 --- a/examples/cogland.c +++ b/examples/cogland.c @@ -38,6 +38,7 @@ typedef struct struct { /* wl_surface.attach */ + CoglBool newly_attached; struct wl_buffer *buffer; struct wl_listener buffer_destroy_listener; int32_t sx; @@ -455,6 +456,7 @@ cogland_surface_attach (struct wl_client *wayland_client, surface->pending.sx = sx; surface->pending.sy = sy; surface->pending.buffer = buffer; + surface->pending.newly_attached = TRUE; if (buffer) wl_signal_add (&buffer->resource.destroy_signal, @@ -524,7 +526,8 @@ cogland_surface_commit (struct wl_client *client, CoglandCompositor *compositor = surface->compositor; /* wl_surface.attach */ - if (surface->buffer != surface->pending.buffer) + if (surface->pending.newly_attached && + surface->buffer != surface->pending.buffer) { CoglError *error = NULL; @@ -557,6 +560,7 @@ cogland_surface_commit (struct wl_client *client, } surface->pending.sx = 0; surface->pending.sy = 0; + surface->pending.newly_attached = FALSE; /* wl_surface.damage */ if (surface->buffer &&