shell: forbid multiple wl_shell_surface objects

Do not allow multiple wl_shell_surface objects to be created for a
wl_surface object.

Multiple shell_surface objects would confuse the compositor as they
contain separate instances of the shell-private data.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
diff --git a/compositor/shell.c b/compositor/shell.c
index 98d5b3f..fd2d4fc 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -410,6 +410,13 @@
 	struct wlsc_surface *surface = surface_resource->data;
 	struct shell_surface *shsurf;
 
+	if (get_shell_surface(surface)) {
+		wl_resource_post_error(surface_resource,
+			WL_DISPLAY_ERROR_INVALID_OBJECT,
+			"wl_shell::get_shell_surface already requested");
+		return;
+	}
+
 	shsurf = calloc(1, sizeof *shsurf);
 	if (!shsurf) {
 		wl_resource_post_no_memory(resource);