xdg-shell: Move xdg_shell.get_xdg_popup errors to xdg_shell

They are errors that may be as a result of calling get_xdg_popup on an
xdg_shell, not a result of calling a request on xdg_popup.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index c903ad7..bcde3fb 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -3398,8 +3398,8 @@
 	    (!parent ||
 	     (top_surface == NULL && !shell_surface_is_xdg_surface(parent)) ||
 	     (top_surface != NULL && parent != top_surface))) {
-		wl_resource_post_error(shsurf->owner->resource,
-				       XDG_POPUP_ERROR_NOT_THE_TOPMOST_POPUP,
+		wl_resource_post_error(shsurf->owner_resource,
+				       XDG_SHELL_ERROR_NOT_THE_TOPMOST_POPUP,
 				       "xdg_popup was not created on the "
 				       "topmost popup");
 		return -1;
@@ -3449,8 +3449,8 @@
 
 	if (shell_surface_is_xdg_popup(shsurf) &&
 	    get_top_popup(shseat) != shsurf) {
-		wl_resource_post_error(shsurf->resource,
-				       XDG_POPUP_ERROR_NOT_THE_TOPMOST_POPUP,
+		wl_resource_post_error(shsurf->owner_resource,
+				       XDG_SHELL_ERROR_NOT_THE_TOPMOST_POPUP,
 				       "xdg_popup was destroyed while it was "
 				       "not the topmost popup.");
 		return;
@@ -4119,21 +4119,7 @@
 		 uint32_t serial,
 		 int32_t x, int32_t y)
 {
-	struct shell_surface *shsurf, *parent_shsurf;
-
-	/* Verify that we are creating the topmost popup when mapping,
-	 * as it's not until then we know whether it was mapped as most
-	 * top level or not. */
-
-	parent_shsurf = get_shell_surface(parent);
-	if (!parent_shsurf ||
-	    (!shell_surface_is_xdg_popup(parent_shsurf) &&
-	     !shell_surface_is_xdg_surface(parent_shsurf))) {
-		wl_resource_post_error(owner->resource,
-				       XDG_POPUP_ERROR_INVALID_PARENT,
-				       "xdg_popup parent was invalid");
-		return NULL;
-	}
+	struct shell_surface *shsurf;
 
 	shsurf = create_common_surface(owner, shell, surface, client);
 	if (!shsurf)
@@ -4164,6 +4150,7 @@
 	struct shell_client *sc = wl_resource_get_user_data(resource);
 	struct desktop_shell *shell = sc->shell;
 	struct shell_surface *shsurf;
+	struct shell_surface *parent_shsurf;
 	struct weston_surface *parent;
 	struct shell_seat *seat;
 
@@ -4189,6 +4176,19 @@
 	parent = wl_resource_get_user_data(parent_resource);
 	seat = get_shell_seat(wl_resource_get_user_data(seat_resource));;
 
+	/* Verify that we are creating the top most popup when mapping,
+	 * as it's not until then we know whether it was mapped as most
+	 * top level or not. */
+
+	parent_shsurf = get_shell_surface(parent);
+	if (!shell_surface_is_xdg_popup(parent_shsurf) &&
+	    !shell_surface_is_xdg_surface(parent_shsurf)) {
+		wl_resource_post_error(resource,
+				       XDG_SHELL_ERROR_INVALID_POPUP_PARENT,
+				       "xdg_popup parent was invalid");
+		return;
+	}
+
 	shsurf = create_xdg_popup(sc, shell, surface, &xdg_popup_client,
 				  parent, seat, serial, x, y);
 	if (!shsurf) {