compositor: Allow attaching null buffer
Attaching a null buffer is allowed and takes the surface back to the
unattached state it starts in.
diff --git a/src/compositor.c b/src/compositor.c
index ab184ac..89981f1 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -530,11 +530,13 @@
struct weston_surface, surface.resource);
struct weston_compositor *compositor = surface->compositor;
- weston_surface_damage_below(surface);
- weston_surface_flush_damage(surface);
+ if (surface->output) {
+ weston_surface_damage_below(surface);
+ weston_surface_flush_damage(surface);
- wl_list_remove(&surface->link);
- weston_compositor_repick(compositor);
+ wl_list_remove(&surface->link);
+ weston_compositor_repick(compositor);
+ }
glDeleteTextures(1, &surface->texture);
@@ -1075,7 +1077,7 @@
{
struct weston_surface *es = resource->data;
struct weston_shell *shell = es->compositor->shell;
- struct wl_buffer *buffer = buffer_resource->data;
+ struct wl_buffer *buffer;
weston_surface_damage_below(es);
@@ -1084,6 +1086,14 @@
wl_list_remove(&es->buffer_destroy_listener.link);
}
+ if (!buffer_resource && es->output) {
+ wl_list_remove(&es->link);
+ es->visual = WESTON_NONE_VISUAL;
+ es->output = NULL;
+ return;
+ }
+
+ buffer = buffer_resource->data;
buffer->busy_count++;
es->buffer = buffer;
wl_list_insert(es->buffer->resource.destroy_listener_list.prev,