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 <robert@linux.intel.com>

(cherry picked from commit aa412b9c709120bd8d88a014010c448f3b9fcfb7)
This commit is contained in:
Neil Roberts 2013-05-02 17:56:38 +01:00
parent 3a7c1263f1
commit 32a0f88b04

View File

@ -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 &&