xdg-shell: validate positioner object

According to the xdg-shell v6 protocol a positioner object is only
complete if both the size and its anchor rectangle are set. Ensure the
weston clients do this and let weston be more strict on checking if a
client has done so.

This also fixes weston-terminal popups not showing up on gnome-shell
3.22.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index 552b330..edd1dc4 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -931,6 +931,15 @@
 	struct weston_desktop_xdg_positioner *positioner =
 		wl_resource_get_user_data(positioner_resource);
 
+	/* Checking whether the size and anchor rect both have a positive size
+	 * is enough to verify both have been correctly set */
+	if (positioner->size.width == 0 || positioner->anchor_rect.width == 0) {
+		wl_resource_post_error(resource,
+				       ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER,
+				       "positioner object is not complete");
+		return;
+	}
+
 	if (weston_surface_set_role(wsurface, weston_desktop_xdg_popup_role,
 				    resource, ZXDG_SHELL_V6_ERROR_ROLE) < 0)
 		return;