compositor: eliminate wlsc_surface::shell_priv

Remove shell_priv member from wlsc_surface, and replace it by a search
through the wl_surface destroy_listener_list.

This technique avoids any "extension" members in the wlsc_surface
structure.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
diff --git a/compositor/compositor.h b/compositor/compositor.h
index fde253c..c47e1bc 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -275,8 +275,6 @@
 
 	struct wl_buffer *buffer;
 	struct wl_listener buffer_destroy_listener;
-
-	void *shell_priv;
 };
 
 void
diff --git a/compositor/shell.c b/compositor/shell.c
index ffa21b4..0d4b182 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -90,12 +90,6 @@
 	int32_t dx, dy;
 };
 
-static struct shell_surface *
-get_shell_surface(struct wlsc_surface *surface)
-{
-	return surface->shell_priv;
-}
-
 static void
 move_grab_motion(struct wl_grab *grab,
 		   uint32_t time, int32_t x, int32_t y)
@@ -390,6 +384,23 @@
 	wl_resource_destroy(&shsurf->resource, time);
 }
 
+static struct shell_surface *
+get_shell_surface(struct wlsc_surface *surface)
+{
+	struct wl_list *lst = &surface->surface.resource.destroy_listener_list;
+	struct wl_listener *listener;
+
+	/* search the destroy listener list for our callback */
+	wl_list_for_each(listener, lst, link) {
+		if (listener->func == shell_handle_surface_destroy) {
+			return container_of(listener, struct shell_surface,
+					    surface_destroy_listener);
+		}
+	}
+
+	return NULL;
+}
+
 static void
 shell_create_shell_surface(struct wl_client *client,
 			   struct wl_resource *resource,
@@ -422,8 +433,6 @@
 
 	shsurf->type = SHELL_SURFACE_NORMAL;
 
-	surface->shell_priv = shsurf;
-
 	wl_client_add_resource(client, &shsurf->resource);
 }