compositor: Move unmap logic to new function weston_surface_unmap()
diff --git a/src/compositor.c b/src/compositor.c
index c690a43..e295aff 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -577,6 +577,17 @@
 }
 
 static void
+weston_surface_unmap(struct weston_surface *surface)
+{
+	weston_surface_damage_below(surface);
+	weston_surface_flush_damage(surface);
+	surface->output = NULL;
+	wl_list_remove(&surface->link);
+	weston_compositor_repick(surface->compositor);
+	weston_compositor_schedule_repaint(surface->compositor);
+}
+
+static void
 destroy_surface(struct wl_resource *resource)
 {
 	struct weston_surface *surface =
@@ -584,13 +595,8 @@
 			     struct weston_surface, surface.resource);
 	struct weston_compositor *compositor = surface->compositor;
 
-	if (surface->output) {
-		weston_surface_damage_below(surface);
-		weston_surface_flush_damage(surface);
-
-		wl_list_remove(&surface->link);
-		weston_compositor_repick(compositor);
-	}
+	if (surface->output)
+		weston_surface_unmap(surface);
 
 	if (surface->texture)
 		glDeleteTextures(1, &surface->texture);
@@ -1130,8 +1136,7 @@
 	}
 
 	if (!buffer_resource && es->output) {
-		wl_list_remove(&es->link);
-		es->output = NULL;
+		weston_surface_unmap(es);
 		es->buffer = NULL;
 		return;
 	}