From 4780f74a4043346c098940a1fdb2eb855b8fe63b Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 25 Nov 2013 16:03:25 -0500 Subject: [PATCH] wayland-surface: Properly allow setting the cursor to a NULL buffer --- src/wayland/meta-wayland-seat.c | 6 +++++- src/wayland/meta-wayland-surface.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c index 012cd00bf..9b853e13d 100644 --- a/src/wayland/meta-wayland-seat.c +++ b/src/wayland/meta-wayland-seat.c @@ -68,7 +68,11 @@ meta_wayland_seat_update_sprite (MetaWaylandSeat *seat) if (seat->cursor_tracker == NULL) return; - buffer = seat->sprite->buffer_ref.buffer->resource; + if (seat->sprite->buffer_ref.buffer) + buffer = seat->sprite->buffer_ref.buffer->resource; + else + buffer = NULL; + meta_cursor_tracker_set_window_cursor (seat->cursor_tracker, buffer, seat->hotspot_x, diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index f5007cf81..ebc215444 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -243,6 +243,9 @@ ensure_buffer_texture (MetaWaylandBuffer *buffer) CoglError *catch_error = NULL; CoglTexture *texture; + if (!buffer) + return; + texture = COGL_TEXTURE (cogl_wayland_texture_2d_new_from_buffer (ctx, buffer->resource, &catch_error)); @@ -277,14 +280,11 @@ meta_wayland_surface_commit (struct wl_client *client, { MetaWaylandBuffer *buffer = surface->pending.buffer; - if (buffer) - { - /* Note: we set this before informing any window-actor since the - * window actor will expect to find the new buffer within the - * surface. */ - ensure_buffer_texture (buffer); - meta_wayland_buffer_reference (&surface->buffer_ref, buffer); - } + /* Note: we set this before informing any window-actor since the + * window actor will expect to find the new buffer within the + * surface. */ + ensure_buffer_texture (buffer); + meta_wayland_buffer_reference (&surface->buffer_ref, buffer); } if (surface == compositor->seat->sprite)