shell: Don't make desktop_shell background a wl_shell_surface

We don't gain anything from taking a wl_shell_surface in
desktop_surface.set_background, except making wl_shell_surface
gratuitously dependent on wl_shell.  In shell.c we can also handle
backgrounds in their own background_configure function which simplifies
the mapping and placement logic.
diff --git a/src/shell.c b/src/shell.c
index 90db992..f1a0170 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -95,7 +95,6 @@
 	struct shell_surface *lock_surface;
 	struct wl_listener lock_surface_listener;
 
-	struct wl_list backgrounds;
 	struct wl_list panels;
 
 	struct {
@@ -133,7 +132,6 @@
 	SHELL_SURFACE_NONE,
 
 	SHELL_SURFACE_PANEL,
-	SHELL_SURFACE_BACKGROUND,
 	SHELL_SURFACE_LOCK,
 	SHELL_SURFACE_SCREENSAVER,
 	SHELL_SURFACE_INPUT_PANEL,
@@ -1229,7 +1227,6 @@
 					    surface->saved_y);
 		break;
 	case SHELL_SURFACE_PANEL:
-	case SHELL_SURFACE_BACKGROUND:
 	case SHELL_SURFACE_INPUT_PANEL:
 		wl_list_remove(&surface->link);
 		wl_list_init(&surface->link);
@@ -1294,22 +1291,6 @@
 		}
 		break;
 
-	case SHELL_SURFACE_BACKGROUND:
-		wl_list_for_each(priv, &shell->backgrounds, link) {
-			if (priv->output == shsurf->output) {
-				priv->surface->output = NULL;
-				wl_list_remove(&priv->surface->layer_link);
-				wl_list_remove(&priv->link);
-				break;
-			}
-		}
-
-		wl_list_insert(&shell->backgrounds, &shsurf->link);
-
-		weston_surface_set_position(surface, shsurf->output->x,
-					    shsurf->output->y);
-		break;
-
 	case SHELL_SURFACE_PANEL:
 		wl_list_for_each(priv, &shell->panels, link) {
 			if (priv->output == shsurf->output) {
@@ -1944,20 +1925,53 @@
 }
 
 static void
+background_configure(struct weston_surface *es, int32_t sx, int32_t sy)
+{
+	struct desktop_shell *shell = es->private;
+	struct weston_surface *s;
+
+	wl_list_for_each(s, &shell->background_layer.surface_list, layer_link) {
+		if (s->output == es->output) {
+			s->output = NULL;
+			wl_list_remove(&s->layer_link);
+			s->configure = NULL;
+			break;
+		}
+	}
+
+	weston_surface_configure(es, es->output->x, es->output->y,
+				 es->buffer->width, es->buffer->height);
+
+	if (wl_list_empty(&es->layer_link)) {
+		wl_list_insert(&shell->background_layer.surface_list,
+			       &es->layer_link);
+		weston_surface_assign_output(es);
+	}
+}
+
+static void
 desktop_shell_set_background(struct wl_client *client,
 			     struct wl_resource *resource,
 			     struct wl_resource *output_resource,
 			     struct wl_resource *surface_resource)
 {
-	struct shell_surface *shsurf = surface_resource->data;
+	struct desktop_shell *shell = resource->data;
+	struct weston_surface *surface = surface_resource->data;
 
-	shsurf->next_type = SHELL_SURFACE_BACKGROUND;
-	shsurf->output = output_resource->data;
+	if (surface->configure) {
+		wl_resource_post_error(surface_resource,
+				       WL_DISPLAY_ERROR_INVALID_OBJECT,
+				       "surface role already assigned");
+		return;
+	}
 
+	surface->configure = background_configure;
+	surface->private = shell;
+	surface->output = output_resource->data;
 	desktop_shell_send_configure(resource, 0,
 				     surface_resource,
-				     shsurf->output->current->width,
-				     shsurf->output->current->height);
+				     surface->output->current->width,
+				     surface->output->current->height);
 }
 
 static void
@@ -1972,7 +1986,7 @@
 	shsurf->output = output_resource->data;
 
 	desktop_shell_send_configure(resource, 0,
-				     surface_resource,
+				     &shsurf->surface->surface.resource,
 				     shsurf->output->current->width,
 				     shsurf->output->current->height);
 }
@@ -2092,7 +2106,6 @@
 
 	switch (shsurf->type) {
 		case SHELL_SURFACE_PANEL:
-		case SHELL_SURFACE_BACKGROUND:
 		case SHELL_SURFACE_FULLSCREEN:
 		case SHELL_SURFACE_SCREENSAVER:
 		case SHELL_SURFACE_INPUT_PANEL:
@@ -2122,7 +2135,6 @@
 
 	switch (shsurf->type) {
 		case SHELL_SURFACE_PANEL:
-		case SHELL_SURFACE_BACKGROUND:
 		case SHELL_SURFACE_FULLSCREEN:
 		case SHELL_SURFACE_SCREENSAVER:
 		case SHELL_SURFACE_INPUT_PANEL:
@@ -2170,7 +2182,6 @@
 		return;
 
 	switch (shsurf->type) {
-		case SHELL_SURFACE_BACKGROUND:
 		case SHELL_SURFACE_SCREENSAVER:
 			return;
 		default:
@@ -2367,7 +2378,6 @@
 
 	switch (surface->type) {
 		case SHELL_SURFACE_PANEL:
-		case SHELL_SURFACE_BACKGROUND:
 		case SHELL_SURFACE_FULLSCREEN:
 		case SHELL_SURFACE_SCREENSAVER:
 		case SHELL_SURFACE_INPUT_PANEL:
@@ -2439,7 +2449,6 @@
 	weston_surface_activate(es, seat);
 
 	switch (get_shell_surface_type(es)) {
-	case SHELL_SURFACE_BACKGROUND:
 	case SHELL_SURFACE_PANEL:
 	case SHELL_SURFACE_LOCK:
 	case SHELL_SURFACE_INPUT_PANEL:
@@ -2498,7 +2507,6 @@
 		focus = upper;
 
 	switch (get_shell_surface_type(focus)) {
-		case SHELL_SURFACE_BACKGROUND:
 		case SHELL_SURFACE_SCREENSAVER:
 		case SHELL_SURFACE_INPUT_PANEL:
 			return;
@@ -2685,11 +2693,6 @@
 
 	/* surface stacking order, see also activate() */
 	switch (surface_type) {
-	case SHELL_SURFACE_BACKGROUND:
-		/* background always visible, at the bottom */
-		wl_list_insert(&shell->background_layer.surface_list,
-			       &surface->layer_link);
-		break;
 	case SHELL_SURFACE_PANEL:
 		/* panel always on top, hidden while locked */
 		wl_list_insert(&shell->panel_layer.surface_list,
@@ -3418,7 +3421,6 @@
 	ec->shell_interface.move = surface_move;
 	ec->shell_interface.resize = surface_resize;
 
-	wl_list_init(&shell->backgrounds);
 	wl_list_init(&shell->panels);
 	wl_list_init(&shell->screensaver.surfaces);
 	wl_list_init(&shell->input_panel.surfaces);