--- wayland-1.21.0.orig/.gitlab-ci.yml
+++ wayland-1.21.0/.gitlab-ci.yml
@@ -74,10 +74,10 @@
     BUILD_OS: debian
     FDO_DISTRIBUTION_VERSION: buster
     FDO_DISTRIBUTION_PACKAGES: 'build-essential pkg-config libexpat1-dev libffi-dev libxml2-dev doxygen graphviz xmlto xsltproc docbook-xsl python3-pip python3-setuptools ninja-build'
-    FDO_DISTRIBUTION_EXEC: 'pip3 install meson==0.56.0'
+    FDO_DISTRIBUTION_EXEC: 'pip3 install meson==0.52.1'
     # bump this tag every time you change something which requires rebuilding the
     # base image
-    FDO_DISTRIBUTION_TAG: "2022-02-05.0"
+    FDO_DISTRIBUTION_TAG: "2021-08-03.0"
 
 .debian-x86_64:
   extends:
--- wayland-1.21.0.orig/cursor/os-compatibility.c
+++ wayland-1.21.0/cursor/os-compatibility.c
@@ -31,9 +31,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <signal.h>
 #include <string.h>
-#include <stdio.h>
 #include <stdlib.h>
 
 #ifdef HAVE_MEMFD_CREATE
@@ -120,7 +118,6 @@
 	static const char template[] = "/wayland-cursor-shared-XXXXXX";
 	const char *path;
 	char *name;
-	size_t name_size;
 	int fd;
 
 #ifdef HAVE_MEMFD_CREATE
@@ -137,17 +134,17 @@
 #endif
 	{
 		path = getenv("XDG_RUNTIME_DIR");
-		if (!path || path[0] != '/') {
+		if (!path) {
 			errno = ENOENT;
 			return -1;
 		}
 
-		name_size = strlen(path) + sizeof(template);
-		name = malloc(name_size);
+		name = malloc(strlen(path) + sizeof(template));
 		if (!name)
 			return -1;
 
-		snprintf(name, name_size, "%s%s", path, template);
+		strcpy(name, path);
+		strcat(name, template);
 
 		fd = create_tmpfile_cloexec(name);
 
@@ -169,28 +166,11 @@
 os_resize_anonymous_file(int fd, off_t size)
 {
 #ifdef HAVE_POSIX_FALLOCATE
-	sigset_t mask;
-	sigset_t old_mask;
-
-	/*
-	 * posix_fallocate() might be interrupted, so we need to check
-	 * for EINTR and retry in that case.
-	 * However, in the presence of an alarm, the interrupt may trigger
-	 * repeatedly and prevent a large posix_fallocate() to ever complete
-	 * successfully, so we need to first block SIGALRM to prevent
-	 * this.
-	 */
-	sigemptyset(&mask);
-	sigaddset(&mask, SIGALRM);
-	sigprocmask(SIG_BLOCK, &mask, &old_mask);
-	/*
-	 * Filesystems that do not support fallocate will return EINVAL or
+	/* 
+	 * Filesystems that do support fallocate will return EINVAL or
 	 * EOPNOTSUPP. In this case we need to fall back to ftruncate
 	 */
-	do {
-		errno = posix_fallocate(fd, 0, size);
-	} while (errno == EINTR);
-	sigprocmask(SIG_SETMASK, &old_mask, NULL);
+	errno = posix_fallocate(fd, 0, size);
 	if (errno == 0)
 		return 0;
 	else if (errno != EINVAL && errno != EOPNOTSUPP)
--- wayland-1.21.0.orig/cursor/wayland-cursor.c
+++ wayland-1.21.0/cursor/wayland-cursor.c
@@ -92,7 +92,7 @@
 
 	pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
 			  pool->fd, 0);
-	if (pool->data == MAP_FAILED)
+	if (pool->data == (void *)-1)
 		return 0;
 	pool->size = size;
 
@@ -274,7 +274,7 @@
 }
 
 static struct wl_cursor *
-wl_cursor_create_from_xcursor_images(struct xcursor_images *images,
+wl_cursor_create_from_xcursor_images(XcursorImages *images,
 				     struct wl_cursor_theme *theme)
 {
 	struct cursor *cursor;
@@ -335,13 +335,13 @@
 }
 
 static void
-load_callback(struct xcursor_images *images, void *data)
+load_callback(XcursorImages *images, void *data)
 {
 	struct wl_cursor_theme *theme = data;
 	struct wl_cursor *cursor;
 
 	if (wl_cursor_theme_get_cursor(theme, images->name)) {
-		xcursor_images_destroy(images);
+		XcursorImagesDestroy(images);
 		return;
 	}
 
@@ -361,7 +361,7 @@
 		}
 	}
 
-	xcursor_images_destroy(images);
+	XcursorImagesDestroy(images);
 }
 
 /** Load a cursor theme to memory shared with the compositor
--- wayland-1.21.0.orig/cursor/xcursor.c
+++ wayland-1.21.0/cursor/xcursor.c
@@ -23,15 +23,20 @@
  * SOFTWARE.
  */
 
-#define _GNU_SOURCE
 #include "xcursor.h"
-#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <dirent.h>
 
 /*
+ * From libXcursor/include/X11/extensions/Xcursor.h
+ */
+
+#define XcursorTrue	1
+#define XcursorFalse	0
+
+/*
  * Cursor files start with a header.  The header
  * contains a magic number, a version number and a
  * table of contents which has type and offset information
@@ -62,31 +67,43 @@
  *	CARD32		position    absolute file position
  */
 
-#define XCURSOR_MAGIC 0x72756358 /* "Xcur" LSBFirst */
+#define XCURSOR_MAGIC	0x72756358  /* "Xcur" LSBFirst */
+
+/*
+ * Current Xcursor version number.  Will be substituted by configure
+ * from the version in the libXcursor configure.ac file.
+ */
+
+#define XCURSOR_LIB_MAJOR 1
+#define XCURSOR_LIB_MINOR 1
+#define XCURSOR_LIB_REVISION 13
+#define XCURSOR_LIB_VERSION	((XCURSOR_LIB_MAJOR * 10000) + \
+				 (XCURSOR_LIB_MINOR * 100) + \
+				 (XCURSOR_LIB_REVISION))
 
 /*
  * This version number is stored in cursor files; changes to the
  * file format require updating this version number
  */
-#define XCURSOR_FILE_MAJOR 1
-#define XCURSOR_FILE_MINOR 0
-#define XCURSOR_FILE_VERSION ((XCURSOR_FILE_MAJOR << 16) | (XCURSOR_FILE_MINOR))
-#define XCURSOR_FILE_HEADER_LEN (4 * 4)
-#define XCURSOR_FILE_TOC_LEN (3 * 4)
-
-struct xcursor_file_toc {
-	uint32_t type; /* chunk type */
-	uint32_t subtype; /* subtype (size for images) */
-	uint32_t position; /* absolute position in file */
-};
-
-struct xcursor_file_header {
-	uint32_t magic; /* magic number */
-	uint32_t header; /* byte length of header */
-	uint32_t version; /* file version number */
-	uint32_t ntoc; /* number of toc entries */
-	struct xcursor_file_toc *tocs; /* table of contents */
-};
+#define XCURSOR_FILE_MAJOR	1
+#define XCURSOR_FILE_MINOR	0
+#define XCURSOR_FILE_VERSION	((XCURSOR_FILE_MAJOR << 16) | (XCURSOR_FILE_MINOR))
+#define XCURSOR_FILE_HEADER_LEN	(4 * 4)
+#define XCURSOR_FILE_TOC_LEN	(3 * 4)
+
+typedef struct _XcursorFileToc {
+    XcursorUInt	    type;	/* chunk type */
+    XcursorUInt	    subtype;	/* subtype (size for images) */
+    XcursorUInt	    position;	/* absolute position in file */
+} XcursorFileToc;
+
+typedef struct _XcursorFileHeader {
+    XcursorUInt	    magic;	/* magic number */
+    XcursorUInt	    header;	/* byte length of header */
+    XcursorUInt	    version;	/* file version number */
+    XcursorUInt	    ntoc;	/* number of toc entries */
+    XcursorFileToc  *tocs;	/* table of contents */
+} XcursorFileHeader;
 
 /*
  * The rest of the file is a list of chunks, each tagged by type
@@ -104,14 +121,42 @@
  *	CARD32	    version	chunk type version
  */
 
-#define XCURSOR_CHUNK_HEADER_LEN (4 * 4)
+#define XCURSOR_CHUNK_HEADER_LEN    (4 * 4)
 
-struct xcursor_chunk_header {
-	uint32_t header; /* bytes in chunk header */
-	uint32_t type; /* chunk type */
-	uint32_t subtype; /* chunk subtype (size for images) */
-	uint32_t version; /* version of this type */
-};
+typedef struct _XcursorChunkHeader {
+    XcursorUInt	    header;	/* bytes in chunk header */
+    XcursorUInt	    type;	/* chunk type */
+    XcursorUInt	    subtype;	/* chunk subtype (size for images) */
+    XcursorUInt	    version;	/* version of this type */
+} XcursorChunkHeader;
+
+/*
+ * Here's a list of the known chunk types
+ */
+
+/*
+ * Comments consist of a 4-byte length field followed by
+ * UTF-8 encoded text
+ *
+ *  Comment:
+ *	ChunkHeader header	chunk header
+ *	CARD32	    length	bytes in text
+ *	LISTofCARD8 text	UTF-8 encoded text
+ */
+
+#define XCURSOR_COMMENT_TYPE	    0xfffe0001
+#define XCURSOR_COMMENT_VERSION	    1
+#define XCURSOR_COMMENT_HEADER_LEN  (XCURSOR_CHUNK_HEADER_LEN + (1 *4))
+#define XCURSOR_COMMENT_COPYRIGHT   1
+#define XCURSOR_COMMENT_LICENSE	    2
+#define XCURSOR_COMMENT_OTHER	    3
+#define XCURSOR_COMMENT_MAX_LEN	    0x100000
+
+typedef struct _XcursorComment {
+    XcursorUInt	    version;
+    XcursorUInt	    comment_type;
+    char	    *comment;
+} XcursorComment;
 
 /*
  * Each cursor image occupies a separate image chunk.
@@ -129,354 +174,439 @@
  *	LISTofCARD32	pixels	ARGB pixels
  */
 
-#define XCURSOR_IMAGE_TYPE 0xfffd0002
-#define XCURSOR_IMAGE_VERSION 1
-#define XCURSOR_IMAGE_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (5*4))
-#define XCURSOR_IMAGE_MAX_SIZE 0x7fff /* 32767x32767 max cursor size */
+#define XCURSOR_IMAGE_TYPE    	    0xfffd0002
+#define XCURSOR_IMAGE_VERSION	    1
+#define XCURSOR_IMAGE_HEADER_LEN    (XCURSOR_CHUNK_HEADER_LEN + (5*4))
+#define XCURSOR_IMAGE_MAX_SIZE	    0x7fff	/* 32767x32767 max cursor size */
+
+typedef struct _XcursorFile XcursorFile;
+
+struct _XcursorFile {
+    void    *closure;
+    int	    (*read)  (XcursorFile *file, unsigned char *buf, int len);
+    int	    (*write) (XcursorFile *file, unsigned char *buf, int len);
+    int	    (*seek)  (XcursorFile *file, long offset, int whence);
+};
+
+typedef struct _XcursorComments {
+    int		    ncomment;	/* number of comments */
+    XcursorComment  **comments;	/* array of XcursorComment pointers */
+} XcursorComments;
 
 /*
  * From libXcursor/src/file.c
  */
 
-static struct xcursor_image *
-xcursor_image_create(int width, int height)
+static XcursorImage *
+XcursorImageCreate (int width, int height)
 {
-	struct xcursor_image *image;
+    XcursorImage    *image;
 
-	if (width < 0 || height < 0)
-		return NULL;
-	if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE)
-		return NULL;
-
-	image = malloc(sizeof(struct xcursor_image) +
-		       width * height * sizeof(uint32_t));
-	if (!image)
-		return NULL;
-	image->version = XCURSOR_IMAGE_VERSION;
-	image->pixels = (uint32_t *) (image + 1);
-	image->size = width > height ? width : height;
-	image->width = width;
-	image->height = height;
-	image->delay = 0;
-	return image;
+    if (width < 0 || height < 0)
+       return NULL;
+    if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE)
+       return NULL;
+
+    image = malloc (sizeof (XcursorImage) +
+		    width * height * sizeof (XcursorPixel));
+    if (!image)
+	return NULL;
+    image->version = XCURSOR_IMAGE_VERSION;
+    image->pixels = (XcursorPixel *) (image + 1);
+    image->size = width > height ? width : height;
+    image->width = width;
+    image->height = height;
+    image->delay = 0;
+    return image;
 }
 
 static void
-xcursor_image_destroy(struct xcursor_image *image)
+XcursorImageDestroy (XcursorImage *image)
 {
-	free(image);
+    free (image);
 }
 
-static struct xcursor_images *
-xcursor_images_create(int size)
+static XcursorImages *
+XcursorImagesCreate (int size)
 {
-	struct xcursor_images *images;
+    XcursorImages   *images;
 
-	images = malloc(sizeof(struct xcursor_images) +
-			size * sizeof(struct xcursor_image *));
-	if (!images)
-		return NULL;
-	images->nimage = 0;
-	images->images = (struct xcursor_image **) (images + 1);
-	images->name = NULL;
-	return images;
+    images = malloc (sizeof (XcursorImages) +
+		     size * sizeof (XcursorImage *));
+    if (!images)
+	return NULL;
+    images->nimage = 0;
+    images->images = (XcursorImage **) (images + 1);
+    images->name = NULL;
+    return images;
 }
 
 void
-xcursor_images_destroy(struct xcursor_images *images)
+XcursorImagesDestroy (XcursorImages *images)
 {
-	int n;
+    int	n;
 
-	if (!images)
-		return;
+    if (!images)
+        return;
 
-	for (n = 0; n < images->nimage; n++)
-		xcursor_image_destroy(images->images[n]);
-	free(images->name);
-	free(images);
+    for (n = 0; n < images->nimage; n++)
+	XcursorImageDestroy (images->images[n]);
+    if (images->name)
+	free (images->name);
+    free (images);
 }
 
-static bool
-xcursor_read_uint(FILE *file, uint32_t *u)
+static void
+XcursorImagesSetName (XcursorImages *images, const char *name)
 {
-	unsigned char bytes[4];
+    char    *new;
+
+    if (!images || !name)
+        return;
 
-	if (!file || !u)
-		return false;
+    new = malloc (strlen (name) + 1);
 
-	if (fread(bytes, 1, 4, file) != 4)
-		return false;
+    if (!new)
+	return;
 
-	*u = ((uint32_t)(bytes[0]) << 0) |
-		 ((uint32_t)(bytes[1]) << 8) |
-		 ((uint32_t)(bytes[2]) << 16) |
-		 ((uint32_t)(bytes[3]) << 24);
-	return true;
+    strcpy (new, name);
+    if (images->name)
+	free (images->name);
+    images->name = new;
 }
 
-static void
-xcursor_file_header_destroy(struct xcursor_file_header *file_header)
+static XcursorBool
+_XcursorReadUInt (XcursorFile *file, XcursorUInt *u)
 {
-	free(file_header);
+    unsigned char   bytes[4];
+
+    if (!file || !u)
+        return XcursorFalse;
+
+    if ((*file->read) (file, bytes, 4) != 4)
+	return XcursorFalse;
+
+    *u = ((XcursorUInt)(bytes[0]) << 0) |
+         ((XcursorUInt)(bytes[1]) << 8) |
+         ((XcursorUInt)(bytes[2]) << 16) |
+         ((XcursorUInt)(bytes[3]) << 24);
+    return XcursorTrue;
 }
 
-static struct xcursor_file_header *
-xcursor_file_header_create(uint32_t ntoc)
+static void
+_XcursorFileHeaderDestroy (XcursorFileHeader *fileHeader)
 {
-	struct xcursor_file_header *file_header;
-
-	if (ntoc > 0x10000)
-		return NULL;
-	file_header = malloc(sizeof(struct xcursor_file_header) +
-			    ntoc * sizeof(struct xcursor_file_toc));
-	if (!file_header)
-		return NULL;
-	file_header->magic = XCURSOR_MAGIC;
-	file_header->header = XCURSOR_FILE_HEADER_LEN;
-	file_header->version = XCURSOR_FILE_VERSION;
-	file_header->ntoc = ntoc;
-	file_header->tocs = (struct xcursor_file_toc *) (file_header + 1);
-	return file_header;
-}
-
-static struct xcursor_file_header *
-xcursor_read_file_header(FILE *file)
-{
-	struct xcursor_file_header head, *file_header;
-	uint32_t skip;
-	unsigned int n;
-
-	if (!file)
-		return NULL;
-
-	if (!xcursor_read_uint(file, &head.magic))
-		return NULL;
-	if (head.magic != XCURSOR_MAGIC)
-		return NULL;
-	if (!xcursor_read_uint(file, &head.header))
-		return NULL;
-	if (!xcursor_read_uint(file, &head.version))
-		return NULL;
-	if (!xcursor_read_uint(file, &head.ntoc))
-		return NULL;
-	skip = head.header - XCURSOR_FILE_HEADER_LEN;
-	if (skip)
-		if (fseek(file, skip, SEEK_CUR) == EOF)
-			return NULL;
-	file_header = xcursor_file_header_create(head.ntoc);
-	if (!file_header)
-		return NULL;
-	file_header->magic = head.magic;
-	file_header->header = head.header;
-	file_header->version = head.version;
-	file_header->ntoc = head.ntoc;
-	for (n = 0; n < file_header->ntoc; n++) {
-		if (!xcursor_read_uint(file, &file_header->tocs[n].type))
-			break;
-		if (!xcursor_read_uint(file, &file_header->tocs[n].subtype))
-			break;
-		if (!xcursor_read_uint(file, &file_header->tocs[n].position))
-			break;
-	}
-	if (n != file_header->ntoc) {
-		xcursor_file_header_destroy(file_header);
-		return NULL;
-	}
-	return file_header;
+    free (fileHeader);
 }
 
-static bool
-xcursor_seek_to_toc(FILE *file,
-		    struct xcursor_file_header *file_header,
-		    int toc)
-{
-	if (!file || !file_header ||
-	    fseek(file, file_header->tocs[toc].position, SEEK_SET) == EOF)
-		return false;
-	return true;
-}
-
-static bool
-xcursor_file_read_chunk_header(FILE *file,
-			       struct xcursor_file_header *file_header,
-			       int toc,
-			       struct xcursor_chunk_header *chunk_header)
-{
-	if (!file || !file_header || !chunk_header)
-		return false;
-	if (!xcursor_seek_to_toc(file, file_header, toc))
-		return false;
-	if (!xcursor_read_uint(file, &chunk_header->header))
-		return false;
-	if (!xcursor_read_uint(file, &chunk_header->type))
-		return false;
-	if (!xcursor_read_uint(file, &chunk_header->subtype))
-		return false;
-	if (!xcursor_read_uint(file, &chunk_header->version))
-		return false;
-	/* sanity check */
-	if (chunk_header->type != file_header->tocs[toc].type ||
-	    chunk_header->subtype != file_header->tocs[toc].subtype)
-		return false;
-	return true;
-}
-
-static uint32_t
-dist(uint32_t a, uint32_t b)
-{
-	return a > b ? a - b : b - a;
-}
-
-static uint32_t
-xcursor_file_best_size(struct xcursor_file_header *file_header,
-		       uint32_t size, int *nsizesp)
-{
-	unsigned int n;
-	int nsizes = 0;
-	uint32_t best_size = 0;
-	uint32_t this_size;
+static XcursorFileHeader *
+_XcursorFileHeaderCreate (XcursorUInt ntoc)
+{
+    XcursorFileHeader	*fileHeader;
+
+    if (ntoc > 0x10000)
+	return NULL;
+    fileHeader = malloc (sizeof (XcursorFileHeader) +
+			 ntoc * sizeof (XcursorFileToc));
+    if (!fileHeader)
+	return NULL;
+    fileHeader->magic = XCURSOR_MAGIC;
+    fileHeader->header = XCURSOR_FILE_HEADER_LEN;
+    fileHeader->version = XCURSOR_FILE_VERSION;
+    fileHeader->ntoc = ntoc;
+    fileHeader->tocs = (XcursorFileToc *) (fileHeader + 1);
+    return fileHeader;
+}
+
+static XcursorFileHeader *
+_XcursorReadFileHeader (XcursorFile *file)
+{
+    XcursorFileHeader	head, *fileHeader;
+    XcursorUInt		skip;
+    unsigned int	n;
+
+    if (!file)
+        return NULL;
+
+    if (!_XcursorReadUInt (file, &head.magic))
+	return NULL;
+    if (head.magic != XCURSOR_MAGIC)
+	return NULL;
+    if (!_XcursorReadUInt (file, &head.header))
+	return NULL;
+    if (!_XcursorReadUInt (file, &head.version))
+	return NULL;
+    if (!_XcursorReadUInt (file, &head.ntoc))
+	return NULL;
+    skip = head.header - XCURSOR_FILE_HEADER_LEN;
+    if (skip)
+	if ((*file->seek) (file, skip, SEEK_CUR) == EOF)
+	    return NULL;
+    fileHeader = _XcursorFileHeaderCreate (head.ntoc);
+    if (!fileHeader)
+	return NULL;
+    fileHeader->magic = head.magic;
+    fileHeader->header = head.header;
+    fileHeader->version = head.version;
+    fileHeader->ntoc = head.ntoc;
+    for (n = 0; n < fileHeader->ntoc; n++)
+    {
+	if (!_XcursorReadUInt (file, &fileHeader->tocs[n].type))
+	    break;
+	if (!_XcursorReadUInt (file, &fileHeader->tocs[n].subtype))
+	    break;
+	if (!_XcursorReadUInt (file, &fileHeader->tocs[n].position))
+	    break;
+    }
+    if (n != fileHeader->ntoc)
+    {
+	_XcursorFileHeaderDestroy (fileHeader);
+	return NULL;
+    }
+    return fileHeader;
+}
+
+static XcursorBool
+_XcursorSeekToToc (XcursorFile		*file,
+		   XcursorFileHeader	*fileHeader,
+		   int			toc)
+{
+    if (!file || !fileHeader || \
+        (*file->seek) (file, fileHeader->tocs[toc].position, SEEK_SET) == EOF)
+	return XcursorFalse;
+    return XcursorTrue;
+}
+
+static XcursorBool
+_XcursorFileReadChunkHeader (XcursorFile	*file,
+			     XcursorFileHeader	*fileHeader,
+			     int		toc,
+			     XcursorChunkHeader	*chunkHeader)
+{
+    if (!file || !fileHeader || !chunkHeader)
+        return XcursorFalse;
+    if (!_XcursorSeekToToc (file, fileHeader, toc))
+	return XcursorFalse;
+    if (!_XcursorReadUInt (file, &chunkHeader->header))
+	return XcursorFalse;
+    if (!_XcursorReadUInt (file, &chunkHeader->type))
+	return XcursorFalse;
+    if (!_XcursorReadUInt (file, &chunkHeader->subtype))
+	return XcursorFalse;
+    if (!_XcursorReadUInt (file, &chunkHeader->version))
+	return XcursorFalse;
+    /* sanity check */
+    if (chunkHeader->type != fileHeader->tocs[toc].type ||
+	chunkHeader->subtype != fileHeader->tocs[toc].subtype)
+	return XcursorFalse;
+    return XcursorTrue;
+}
+
+#define dist(a,b)   ((a) > (b) ? (a) - (b) : (b) - (a))
+
+static XcursorDim
+_XcursorFindBestSize (XcursorFileHeader *fileHeader,
+		      XcursorDim	size,
+		      int		*nsizesp)
+{
+    unsigned int n;
+    int		nsizes = 0;
+    XcursorDim	bestSize = 0;
+    XcursorDim	thisSize;
+
+    if (!fileHeader || !nsizesp)
+        return 0;
+
+    for (n = 0; n < fileHeader->ntoc; n++)
+    {
+	if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE)
+	    continue;
+	thisSize = fileHeader->tocs[n].subtype;
+	if (!bestSize || dist (thisSize, size) < dist (bestSize, size))
+	{
+	    bestSize = thisSize;
+	    nsizes = 1;
+	}
+	else if (thisSize == bestSize)
+	    nsizes++;
+    }
+    *nsizesp = nsizes;
+    return bestSize;
+}
 
-	if (!file_header || !nsizesp)
-		return 0;
+static int
+_XcursorFindImageToc (XcursorFileHeader	*fileHeader,
+		      XcursorDim	size,
+		      int		count)
+{
+    unsigned int	toc;
+    XcursorDim		thisSize;
+
+    if (!fileHeader)
+        return 0;
+
+    for (toc = 0; toc < fileHeader->ntoc; toc++)
+    {
+	if (fileHeader->tocs[toc].type != XCURSOR_IMAGE_TYPE)
+	    continue;
+	thisSize = fileHeader->tocs[toc].subtype;
+	if (thisSize != size)
+	    continue;
+	if (!count)
+	    break;
+	count--;
+    }
+    if (toc == fileHeader->ntoc)
+	return -1;
+    return toc;
+}
+
+static XcursorImage *
+_XcursorReadImage (XcursorFile		*file,
+		   XcursorFileHeader	*fileHeader,
+		   int			toc)
+{
+    XcursorChunkHeader	chunkHeader;
+    XcursorImage	head;
+    XcursorImage	*image;
+    int			n;
+    XcursorPixel	*p;
+
+    if (!file || !fileHeader)
+        return NULL;
+
+    if (!_XcursorFileReadChunkHeader (file, fileHeader, toc, &chunkHeader))
+	return NULL;
+    if (!_XcursorReadUInt (file, &head.width))
+	return NULL;
+    if (!_XcursorReadUInt (file, &head.height))
+	return NULL;
+    if (!_XcursorReadUInt (file, &head.xhot))
+	return NULL;
+    if (!_XcursorReadUInt (file, &head.yhot))
+	return NULL;
+    if (!_XcursorReadUInt (file, &head.delay))
+	return NULL;
+    /* sanity check data */
+    if (head.width > XCURSOR_IMAGE_MAX_SIZE  ||
+	head.height > XCURSOR_IMAGE_MAX_SIZE)
+	return NULL;
+    if (head.width == 0 || head.height == 0)
+	return NULL;
+    if (head.xhot > head.width || head.yhot > head.height)
+	return NULL;
+
+    /* Create the image and initialize it */
+    image = XcursorImageCreate (head.width, head.height);
+    if (image == NULL)
+	    return NULL;
+    if (chunkHeader.version < image->version)
+	image->version = chunkHeader.version;
+    image->size = chunkHeader.subtype;
+    image->xhot = head.xhot;
+    image->yhot = head.yhot;
+    image->delay = head.delay;
+    n = image->width * image->height;
+    p = image->pixels;
+    while (n--)
+    {
+	if (!_XcursorReadUInt (file, p))
+	{
+	    XcursorImageDestroy (image);
+	    return NULL;
+	}
+	p++;
+    }
+    return image;
+}
+
+static XcursorImages *
+XcursorXcFileLoadImages (XcursorFile *file, int size)
+{
+    XcursorFileHeader	*fileHeader;
+    XcursorDim		bestSize;
+    int			nsize;
+    XcursorImages	*images;
+    int			n;
+    int			toc;
+
+    if (!file || size < 0)
+	return NULL;
+    fileHeader = _XcursorReadFileHeader (file);
+    if (!fileHeader)
+	return NULL;
+    bestSize = _XcursorFindBestSize (fileHeader, (XcursorDim) size, &nsize);
+    if (!bestSize)
+    {
+        _XcursorFileHeaderDestroy (fileHeader);
+	return NULL;
+    }
+    images = XcursorImagesCreate (nsize);
+    if (!images)
+    {
+        _XcursorFileHeaderDestroy (fileHeader);
+	return NULL;
+    }
+    for (n = 0; n < nsize; n++)
+    {
+	toc = _XcursorFindImageToc (fileHeader, bestSize, n);
+	if (toc < 0)
+	    break;
+	images->images[images->nimage] = _XcursorReadImage (file, fileHeader,
+							    toc);
+	if (!images->images[images->nimage])
+	    break;
+	images->nimage++;
+    }
+    _XcursorFileHeaderDestroy (fileHeader);
+    if (images->nimage != nsize)
+    {
+	XcursorImagesDestroy (images);
+	images = NULL;
+    }
+    return images;
+}
 
-	for (n = 0; n < file_header->ntoc; n++) {
-		if (file_header->tocs[n].type != XCURSOR_IMAGE_TYPE)
-			continue;
-		this_size = file_header->tocs[n].subtype;
-		if (!best_size || dist(this_size, size) < dist(best_size, size)) {
-			best_size = this_size;
-			nsizes = 1;
-		} else if (this_size == best_size) {
-			nsizes++;
-		}
-	}
-	*nsizesp = nsizes;
-	return best_size;
+static int
+_XcursorStdioFileRead (XcursorFile *file, unsigned char *buf, int len)
+{
+    FILE    *f = file->closure;
+    return fread (buf, 1, len, f);
 }
 
 static int
-xcursor_find_image_toc(struct xcursor_file_header *file_header,
-		       uint32_t size, int count)
+_XcursorStdioFileWrite (XcursorFile *file, unsigned char *buf, int len)
 {
-	unsigned int toc;
-	uint32_t this_size;
+    FILE    *f = file->closure;
+    return fwrite (buf, 1, len, f);
+}
 
-	if (!file_header)
-		return 0;
+static int
+_XcursorStdioFileSeek (XcursorFile *file, long offset, int whence)
+{
+    FILE    *f = file->closure;
+    return fseek (f, offset, whence);
+}
 
-	for (toc = 0; toc < file_header->ntoc; toc++) {
-		if (file_header->tocs[toc].type != XCURSOR_IMAGE_TYPE)
-			continue;
-		this_size = file_header->tocs[toc].subtype;
-		if (this_size != size)
-			continue;
-		if (!count)
-			break;
-		count--;
-	}
-	if (toc == file_header->ntoc)
-		return -1;
-	return toc;
-}
-
-static struct xcursor_image *
-xcursor_read_image(FILE *file,
-		   struct xcursor_file_header *file_header,
-		   int toc)
-{
-	struct xcursor_chunk_header chunk_header;
-	struct xcursor_image head;
-	struct xcursor_image *image;
-	int n;
-	uint32_t *p;
-
-	if (!file || !file_header)
-		return NULL;
-
-	if (!xcursor_file_read_chunk_header(file, file_header, toc, &chunk_header))
-		return NULL;
-	if (!xcursor_read_uint(file, &head.width))
-		return NULL;
-	if (!xcursor_read_uint(file, &head.height))
-		return NULL;
-	if (!xcursor_read_uint(file, &head.xhot))
-		return NULL;
-	if (!xcursor_read_uint(file, &head.yhot))
-		return NULL;
-	if (!xcursor_read_uint(file, &head.delay))
-		return NULL;
-	/* sanity check data */
-	if (head.width > XCURSOR_IMAGE_MAX_SIZE ||
-	    head.height > XCURSOR_IMAGE_MAX_SIZE)
-		return NULL;
-	if (head.width == 0 || head.height == 0)
-		return NULL;
-	if (head.xhot > head.width || head.yhot > head.height)
-		return NULL;
-
-	/* Create the image and initialize it */
-	image = xcursor_image_create(head.width, head.height);
-	if (image == NULL)
-		return NULL;
-	if (chunk_header.version < image->version)
-		image->version = chunk_header.version;
-	image->size = chunk_header.subtype;
-	image->xhot = head.xhot;
-	image->yhot = head.yhot;
-	image->delay = head.delay;
-	n = image->width * image->height;
-	p = image->pixels;
-	while (n--) {
-		if (!xcursor_read_uint(file, p)) {
-			xcursor_image_destroy(image);
-			return NULL;
-		}
-		p++;
-	}
-	return image;
+static void
+_XcursorStdioFileInitialize (FILE *stdfile, XcursorFile *file)
+{
+    file->closure = stdfile;
+    file->read = _XcursorStdioFileRead;
+    file->write = _XcursorStdioFileWrite;
+    file->seek = _XcursorStdioFileSeek;
 }
 
-static struct xcursor_images *
-xcursor_xc_file_load_images(FILE *file, int size)
+static XcursorImages *
+XcursorFileLoadImages (FILE *file, int size)
 {
-	struct xcursor_file_header *file_header;
-	uint32_t best_size;
-	int nsize;
-	struct xcursor_images *images;
-	int n;
-	int toc;
-
-	if (!file || size < 0)
-		return NULL;
-	file_header = xcursor_read_file_header(file);
-	if (!file_header)
-		return NULL;
-	best_size = xcursor_file_best_size(file_header, (uint32_t) size, &nsize);
-	if (!best_size) {
-		xcursor_file_header_destroy(file_header);
-		return NULL;
-	}
-	images = xcursor_images_create(nsize);
-	if (!images) {
-		xcursor_file_header_destroy(file_header);
-		return NULL;
-	}
-	for (n = 0; n < nsize; n++) {
-		toc = xcursor_find_image_toc(file_header, best_size, n);
-		if (toc < 0)
-			break;
-		images->images[images->nimage] = xcursor_read_image(file, file_header,
-								    toc);
-		if (!images->images[images->nimage])
-			break;
-		images->nimage++;
-	}
-	xcursor_file_header_destroy(file_header);
-	if (images->nimage != nsize) {
-		xcursor_images_destroy(images);
-		images = NULL;
-	}
-	return images;
+    XcursorFile	f;
+
+    if (!file)
+        return NULL;
+
+    _XcursorStdioFileInitialize (file, &f);
+    return XcursorXcFileLoadImages (&f, size);
 }
 
 /*
@@ -504,200 +634,292 @@
  * and must be freed by the caller.
  */
 static char *
-xcursor_library_path(void)
+XcursorLibraryPath (void)
 {
-	const char *env_var, *suffix;
-	char *path;
-	size_t path_size;
-
-	env_var = getenv("XCURSOR_PATH");
-	if (env_var)
-		return strdup(env_var);
-
-	env_var = getenv("XDG_DATA_HOME");
-	if (!env_var || env_var[0] != '/')
-		env_var = XDG_DATA_HOME_FALLBACK;
-
-	suffix = CURSORDIR ":" XCURSORPATH;
-	path_size = strlen(env_var) + strlen(suffix) + 1;
-	path = malloc(path_size);
-	if (!path)
-		return NULL;
-	snprintf(path, path_size, "%s%s", env_var, suffix);
-	return path;
+    const char		*env_var;
+    char		*path = NULL;
+    int		pathlen = 0;
+
+    env_var = getenv ("XCURSOR_PATH");
+    if (env_var)
+    {
+	path = strdup (env_var);
+    }
+    else
+    {
+	env_var = getenv ("XDG_DATA_HOME");
+	if (env_var) {
+            pathlen = strlen (env_var) + strlen (CURSORDIR ":" XCURSORPATH) + 1;
+            path = malloc (pathlen);
+            snprintf (path, pathlen, "%s%s", env_var,
+                      CURSORDIR ":" XCURSORPATH);
+	}
+	else
+	{
+	    path = strdup (XDG_DATA_HOME_FALLBACK CURSORDIR ":" XCURSORPATH);
+	}
+    }
+    return path;
+}
+
+static  void
+_XcursorAddPathElt (char *path, const char *elt, int len)
+{
+    int	    pathlen = strlen (path);
+
+    /* append / if the path doesn't currently have one */
+    if (path[0] == '\0' || path[pathlen - 1] != '/')
+    {
+	strcat (path, "/");
+	pathlen++;
+    }
+    if (len == -1)
+	len = strlen (elt);
+    /* strip leading slashes */
+    while (len && elt[0] == '/')
+    {
+	elt++;
+	len--;
+    }
+    strncpy (path + pathlen, elt, len);
+    path[pathlen + len] = '\0';
 }
 
 static char *
-xcursor_build_theme_dir(const char *dir, const char *theme)
+_XcursorBuildThemeDir (const char *dir, const char *theme)
 {
-	const char *colon;
-	const char *tcolon;
-	char *full;
-	const char *home, *homesep;
-	int dirlen;
-	int homelen;
-	int themelen;
-	size_t full_size;
-
-	if (!dir || !theme)
-		return NULL;
-
-	colon = strchr(dir, ':');
-	if (!colon)
-		colon = dir + strlen(dir);
-
-	dirlen = colon - dir;
-
-	tcolon = strchr(theme, ':');
-	if (!tcolon)
-		tcolon = theme + strlen(theme);
-
-	themelen = tcolon - theme;
-
-	home = "";
-	homelen = 0;
-	homesep = "";
-	if (*dir == '~') {
-		home = getenv("HOME");
-		if (!home)
-			return NULL;
-		homelen = strlen(home);
-		homesep = "/";
-		dir++;
-		dirlen--;
-	}
-
-	/*
-	 * add space for any needed directory separators, one per component,
-	 * and one for the trailing null
-	 */
-	full_size = 1 + homelen + 1 + dirlen + 1 + themelen + 1;
-	full = malloc(full_size);
-	if (!full)
-		return NULL;
-	snprintf(full, full_size, "%s%s%.*s/%.*s", home, homesep,
-		 dirlen, dir, themelen, theme);
-	return full;
+    const char	    *colon;
+    const char	    *tcolon;
+    char	    *full;
+    char	    *home;
+    int		    dirlen;
+    int		    homelen;
+    int		    themelen;
+    int		    len;
+
+    if (!dir || !theme)
+        return NULL;
+
+    colon = strchr (dir, ':');
+    if (!colon)
+	colon = dir + strlen (dir);
+
+    dirlen = colon - dir;
+
+    tcolon = strchr (theme, ':');
+    if (!tcolon)
+	tcolon = theme + strlen (theme);
+
+    themelen = tcolon - theme;
+
+    home = NULL;
+    homelen = 0;
+    if (*dir == '~')
+    {
+	home = getenv ("HOME");
+	if (!home)
+	    return NULL;
+	homelen = strlen (home);
+	dir++;
+	dirlen--;
+    }
+
+    /*
+     * add space for any needed directory separators, one per component,
+     * and one for the trailing null
+     */
+    len = 1 + homelen + 1 + dirlen + 1 + themelen + 1;
+
+    full = malloc (len);
+    if (!full)
+	return NULL;
+    full[0] = '\0';
+
+    if (home)
+	_XcursorAddPathElt (full, home, -1);
+    _XcursorAddPathElt (full, dir, dirlen);
+    _XcursorAddPathElt (full, theme, themelen);
+    return full;
 }
 
 static char *
-xcursor_build_fullname(const char *dir, const char *subdir, const char *file)
+_XcursorBuildFullname (const char *dir, const char *subdir, const char *file)
 {
-	char *full;
-	size_t full_size;
+    char    *full;
 
-	if (!dir || !subdir || !file)
-		return NULL;
+    if (!dir || !subdir || !file)
+        return NULL;
 
-	full_size = strlen(dir) + 1 + strlen(subdir) + 1 + strlen(file) + 1;
-	full = malloc(full_size);
-	if (!full)
-		return NULL;
-	snprintf(full, full_size, "%s/%s/%s", dir, subdir, file);
-	return full;
+    full = malloc (strlen (dir) + 1 + strlen (subdir) + 1 + strlen (file) + 1);
+    if (!full)
+	return NULL;
+    full[0] = '\0';
+    _XcursorAddPathElt (full, dir, -1);
+    _XcursorAddPathElt (full, subdir, -1);
+    _XcursorAddPathElt (full, file, -1);
+    return full;
 }
 
 static const char *
-xcursor_next_path(const char *path)
+_XcursorNextPath (const char *path)
 {
-	char *colon = strchr(path, ':');
-
-	if (!colon)
-		return NULL;
-	return colon + 1;
-}
+    char    *colon = strchr (path, ':');
 
-static bool
-xcursor_white(char c)
-{
-	return c == ' ' || c == '\t' || c == '\n';
+    if (!colon)
+	return NULL;
+    return colon + 1;
 }
 
-static bool
-xcursor_sep(char c)
-{
-	return c == ';' || c == ',';
-}
+#define XcursorWhite(c)	((c) == ' ' || (c) == '\t' || (c) == '\n')
+#define XcursorSep(c) ((c) == ';' || (c) == ',')
 
 static char *
-xcursor_theme_inherits(const char *full)
+_XcursorThemeInherits (const char *full)
 {
-	char *line = NULL;
-	size_t line_size = 0;
-	char *result = NULL;
-	FILE *f;
-
-	if (!full)
-		return NULL;
-
-	f = fopen(full, "r");
-	if (!f)
-		return NULL;
-
-	while (getline(&line, &line_size, f) >= 0) {
-		const char *l;
-		char *r;
-
-		if (strncmp(line, "Inherits", 8))
-			continue;
-
-		l = line + 8;
-		while (*l == ' ')
-			l++;
-		if (*l != '=')
-			continue;
+    char    line[8192];
+    char    *result = NULL;
+    FILE    *f;
+
+    if (!full)
+        return NULL;
+
+    f = fopen (full, "r");
+    if (f)
+    {
+	while (fgets (line, sizeof (line), f))
+	{
+	    if (!strncmp (line, "Inherits", 8))
+	    {
+		char    *l = line + 8;
+		char    *r;
+		while (*l == ' ') l++;
+		if (*l != '=') continue;
 		l++;
-		while (*l == ' ')
-			l++;
-		result = malloc(strlen(l) + 1);
-		if (!result)
-			break;
-
-		r = result;
-		while (*l) {
-			while (xcursor_sep(*l) || xcursor_white(*l))
-				l++;
+		while (*l == ' ') l++;
+		result = malloc (strlen (l) + 1);
+		if (result)
+		{
+		    r = result;
+		    while (*l)
+		    {
+			while (XcursorSep(*l) || XcursorWhite (*l)) l++;
 			if (!*l)
-				break;
+			    break;
 			if (r != result)
-				*r++ = ':';
-			while (*l && !xcursor_white(*l) && !xcursor_sep(*l))
-				*r++ = *l++;
+			    *r++ = ':';
+			while (*l && !XcursorWhite(*l) &&
+			       !XcursorSep(*l))
+			    *r++ = *l++;
+		    }
+		    *r++ = '\0';
 		}
-		*r++ = '\0';
-
 		break;
+	    }
 	}
-
-	fclose(f);
-	free(line);
-
-	return result;
+	fclose (f);
+    }
+    return result;
+}
+
+static FILE *
+XcursorScanTheme (const char *theme, const char *name)
+{
+    FILE	*f = NULL;
+    char	*full;
+    char	*dir;
+    const char  *path;
+    char	*inherits = NULL;
+    const char	*i;
+    char	*xcursor_path;
+
+    if (!theme || !name)
+        return NULL;
+
+    /*
+     * Scan this theme
+     */
+    xcursor_path = XcursorLibraryPath ();
+    for (path = xcursor_path;
+	 path && f == NULL;
+	 path = _XcursorNextPath (path))
+    {
+	dir = _XcursorBuildThemeDir (path, theme);
+	if (dir)
+	{
+	    full = _XcursorBuildFullname (dir, "cursors", name);
+	    if (full)
+	    {
+		f = fopen (full, "r");
+		free (full);
+	    }
+	    if (!f && !inherits)
+	    {
+		full = _XcursorBuildFullname (dir, "", "index.theme");
+		if (full)
+		{
+		    inherits = _XcursorThemeInherits (full);
+		    free (full);
+		}
+	    }
+	    free (dir);
+	}
+    }
+    /*
+     * Recurse to scan inherited themes
+     */
+    for (i = inherits; i && f == NULL; i = _XcursorNextPath (i))
+	f = XcursorScanTheme (i, name);
+    if (inherits != NULL)
+	free (inherits);
+    free (xcursor_path);
+    return f;
+}
+
+XcursorImages *
+XcursorLibraryLoadImages (const char *file, const char *theme, int size)
+{
+    FILE	    *f = NULL;
+    XcursorImages   *images = NULL;
+
+    if (!file)
+        return NULL;
+
+    if (theme)
+	f = XcursorScanTheme (theme, file);
+    if (!f)
+	f = XcursorScanTheme ("default", file);
+    if (f)
+    {
+	images = XcursorFileLoadImages (f, size);
+	if (images)
+	    XcursorImagesSetName (images, file);
+	fclose (f);
+    }
+    return images;
 }
 
 static void
 load_all_cursors_from_dir(const char *path, int size,
-			  void (*load_callback)(struct xcursor_images *, void *),
+			  void (*load_callback)(XcursorImages *, void *),
 			  void *user_data)
 {
 	FILE *f;
 	DIR *dir = opendir(path);
 	struct dirent *ent;
 	char *full;
-	struct xcursor_images *images;
+	XcursorImages *images;
 
 	if (!dir)
 		return;
 
-	for (ent = readdir(dir); ent; ent = readdir(dir)) {
+	for(ent = readdir(dir); ent; ent = readdir(dir)) {
 #ifdef _DIRENT_HAVE_D_TYPE
 		if (ent->d_type != DT_UNKNOWN &&
-		    ent->d_type != DT_REG &&
-		    ent->d_type != DT_LNK)
+		    (ent->d_type != DT_REG && ent->d_type != DT_LNK))
 			continue;
 #endif
 
-		full = xcursor_build_fullname(path, "", ent->d_name);
+		full = _XcursorBuildFullname(path, "", ent->d_name);
 		if (!full)
 			continue;
 
@@ -707,14 +929,14 @@
 			continue;
 		}
 
-		images = xcursor_xc_file_load_images(f, size);
+		images = XcursorFileLoadImages(f, size);
 
 		if (images) {
-			images->name = strdup(ent->d_name);
+			XcursorImagesSetName(images, ent->d_name);
 			load_callback(images, user_data);
 		}
 
-		fclose(f);
+		fclose (f);
 		free(full);
 	}
 
@@ -724,26 +946,26 @@
 /** Load all the cursor of a theme
  *
  * This function loads all the cursor images of a given theme and its
- * inherited themes. Each cursor is loaded into an struct xcursor_images object
+ * inherited themes. Each cursor is loaded into an XcursorImages object
  * which is passed to the caller's load callback. If a cursor appears
  * more than once across all the inherited themes, the load callback
- * will be called multiple times, with possibly different struct xcursor_images
+ * will be called multiple times, with possibly different XcursorImages
  * object which have the same name. The user is expected to destroy the
- * struct xcursor_images objects passed to the callback with
- * xcursor_images_destroy().
+ * XcursorImages objects passed to the callback with
+ * XcursorImagesDestroy().
  *
  * \param theme The name of theme that should be loaded
  * \param size The desired size of the cursor images
  * \param load_callback A callback function that will be called
- * for each cursor loaded. The first parameter is the struct xcursor_images
+ * for each cursor loaded. The first parameter is the XcursorImages
  * object representing the loaded cursor and the second is a pointer
  * to data provided by the user.
  * \param user_data The data that should be passed to the load callback
  */
 void
 xcursor_load_theme(const char *theme, int size,
-		   void (*load_callback)(struct xcursor_images *, void *),
-		   void *user_data)
+		    void (*load_callback)(XcursorImages *, void *),
+		    void *user_data)
 {
 	char *full, *dir;
 	char *inherits = NULL;
@@ -753,31 +975,38 @@
 	if (!theme)
 		theme = "default";
 
-	xcursor_path = xcursor_library_path();
+	xcursor_path = XcursorLibraryPath();
 	for (path = xcursor_path;
 	     path;
-	     path = xcursor_next_path(path)) {
-		dir = xcursor_build_theme_dir(path, theme);
+	     path = _XcursorNextPath(path)) {
+		dir = _XcursorBuildThemeDir(path, theme);
 		if (!dir)
 			continue;
 
-		full = xcursor_build_fullname(dir, "cursors", "");
-		load_all_cursors_from_dir(full, size, load_callback,
-					  user_data);
-		free(full);
+		full = _XcursorBuildFullname(dir, "cursors", "");
 
-		if (!inherits) {
-			full = xcursor_build_fullname(dir, "", "index.theme");
-			inherits = xcursor_theme_inherits(full);
+		if (full) {
+			load_all_cursors_from_dir(full, size, load_callback,
+						  user_data);
 			free(full);
 		}
 
+		if (!inherits) {
+			full = _XcursorBuildFullname(dir, "", "index.theme");
+			if (full) {
+				inherits = _XcursorThemeInherits(full);
+				free(full);
+			}
+		}
+
 		free(dir);
 	}
 
-	for (i = inherits; i; i = xcursor_next_path(i))
+	for (i = inherits; i; i = _XcursorNextPath(i))
 		xcursor_load_theme(i, size, load_callback, user_data);
 
-	free(inherits);
-	free(xcursor_path);
+	if (inherits)
+		free(inherits);
+
+	free (xcursor_path);
 }
--- wayland-1.21.0.orig/cursor/xcursor.h
+++ wayland-1.21.0/cursor/xcursor.h
@@ -28,31 +28,40 @@
 
 #include <stdint.h>
 
-struct xcursor_image {
-	uint32_t version; /* version of the image data */
-	uint32_t size; /* nominal size for matching */
-	uint32_t width; /* actual width */
-	uint32_t height; /* actual height */
-	uint32_t xhot; /* hot spot x (must be inside image) */
-	uint32_t yhot; /* hot spot y (must be inside image) */
-	uint32_t delay; /* animation delay to next frame (ms) */
-	uint32_t *pixels; /* pointer to pixels */
-};
+typedef int		XcursorBool;
+typedef uint32_t	XcursorUInt;
+
+typedef XcursorUInt	XcursorDim;
+typedef XcursorUInt	XcursorPixel;
+
+typedef struct _XcursorImage {
+    XcursorUInt	    version;	/* version of the image data */
+    XcursorDim	    size;	/* nominal size for matching */
+    XcursorDim	    width;	/* actual width */
+    XcursorDim	    height;	/* actual height */
+    XcursorDim	    xhot;	/* hot spot x (must be inside image) */
+    XcursorDim	    yhot;	/* hot spot y (must be inside image) */
+    XcursorUInt	    delay;	/* animation delay to next frame (ms) */
+    XcursorPixel    *pixels;	/* pointer to pixels */
+} XcursorImage;
 
 /*
  * Other data structures exposed by the library API
  */
-struct xcursor_images {
-	int nimage; /* number of images */
-	struct xcursor_image **images; /* array of XcursorImage pointers */
-	char *name; /* name used to load images */
-};
+typedef struct _XcursorImages {
+    int		    nimage;	/* number of images */
+    XcursorImage    **images;	/* array of XcursorImage pointers */
+    char	    *name;	/* name used to load images */
+} XcursorImages;
+
+XcursorImages *
+XcursorLibraryLoadImages (const char *file, const char *theme, int size);
 
 void
-xcursor_images_destroy(struct xcursor_images *images);
+XcursorImagesDestroy (XcursorImages *images);
 
 void
 xcursor_load_theme(const char *theme, int size,
-		   void (*load_callback)(struct xcursor_images *, void *),
-		   void *user_data);
+		    void (*load_callback)(XcursorImages *, void *),
+		    void *user_data);
 #endif
--- wayland-1.21.0.orig/debian/README.source
+++ wayland-1.21.0/debian/README.source
@@ -0,0 +1,61 @@
+Useful upstream remote:
+git remote add upstream https://gitlab.freedesktop.org/wayland/wayland.git
+
+This package uses quilt to manage all modifications to the upstream
+source.  Changes are stored in the source package as diffs in
+debian/patches and applied during the build.
+
+To configure quilt to use debian/patches instead of patches, you want
+either to export QUILT_PATCHES=debian/patches in your environment
+or use this snippet in your ~/.quiltrc:
+
+    for where in ./ ../ ../../ ../../../ ../../../../ ../../../../../; do
+        if [ -e ${where}debian/rules -a -d ${where}debian/patches ]; then
+                export QUILT_PATCHES=debian/patches
+                break
+        fi
+    done
+
+To get the fully patched source after unpacking the source package, cd to
+the root level of the source package and run:
+
+    quilt push -a
+
+The last patch listed in debian/patches/series will become the current
+patch.
+
+To add a new set of changes, first run quilt push -a, and then run:
+
+    quilt new <patch>
+
+where <patch> is a descriptive name for the patch, used as the filename in
+debian/patches.  Then, for every file that will be modified by this patch,
+run:
+
+    quilt add <file>
+
+before editing those files.  You must tell quilt with quilt add what files
+will be part of the patch before making changes or quilt will not work
+properly.  After editing the files, run:
+
+    quilt refresh
+
+to save the results as a patch.
+
+Alternately, if you already have an external patch and you just want to
+add it to the build system, run quilt push -a and then:
+
+    quilt import -P <patch> /path/to/patch
+    quilt push -a
+
+(add -p 0 to quilt import if needed). <patch> as above is the filename to
+use in debian/patches.  The last quilt push -a will apply the patch to
+make sure it works properly.
+
+To remove an existing patch from the list of patches that will be applied,
+run:
+
+    quilt delete <patch>
+
+You may need to run quilt pop -a to unapply patches first before running
+this command.
--- wayland-1.21.0.orig/debian/changelog
+++ wayland-1.21.0/debian/changelog
@@ -0,0 +1,483 @@
+wayland (1.21.0-0xneon+20.04+focal+release+build9) focal; urgency=medium
+
+  [ Jonathan Riddell ]
+  * new release
+
+  [ Neon CI ]
+  * Automatic CI Build
+
+ -- Neon CI <neon@kde.org>  Fri, 21 Oct 2022 10:05:14 +0000
+
+wayland (1.20.0-1) unstable; urgency=medium
+
+  * New upstream release.
+  * debian/libwayland-client0.symbols: refresh
+  * debian/libwayland-server0.symbols: refresh
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Tue, 01 Feb 2022 18:10:38 +0100
+
+wayland (1.19.0-2) unstable; urgency=high
+
+  * Add missing dependency on libffi-dev (closes: #969284).
+    Thanks Julien Cristau for NMU fix at 1.18.0-2~exp1.1
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Mon, 08 Mar 2021 22:56:41 +0100
+
+wayland (1.19.0-1) unstable; urgency=high
+
+  * New upstream release
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Thu, 04 Mar 2021 19:58:06 +0100
+
+wayland (1.18.0-2~exp1) unstable; urgency=medium
+
+  * Switch build system to meson
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Wed, 12 Aug 2020 13:38:40 +0200
+
+wayland (1.18.0-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Wed, 12 Feb 2020 11:08:11 +0100
+
+wayland (1.17.93-1~exp1) experimental; urgency=medium
+
+  * RC1 for Wayland 1.18
+  * debian/control: bump Standards-Version, no changes
+  * debian/*.symbols: update
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Sun, 09 Feb 2020 20:56:23 +0100
+
+wayland (1.17.0-1) unstable; urgency=medium
+
+  [ Timo Aaltonen ]
+  * control: Bump breaks/replaces on libwayland-egl-mesa/libegl1-mesa-
+    dev, which got updated on Ubuntu.
+
+  [ Héctor Orón Martínez ]
+  * New upstream release
+  * debian/README.source: add upstream remote information
+  * debian/libwayland-server0.symbols: update symbols file
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Sun, 21 Jul 2019 20:30:10 +0200
+
+wayland (1.16.0-1) unstable; urgency=medium
+
+  [ Emilio Pozuelo Monfort ]
+  * Update the watch file for the new upstream website layout.
+
+  [ Salvatore Bonaccorso ]
+  * Add debian/changelog entry for 1.14.0-2 (Closes: #903748)
+
+  [ Timo Aaltonen ]
+  * New upstream release.
+
+ -- Timo Aaltonen <tjaalton@debian.org>  Wed, 05 Sep 2018 20:20:03 +0300
+
+wayland (1.15.0-2) unstable; urgency=medium
+
+  * debian/copyright: add missing copyright holders. Closes: #897362.
+  * Update Vcs-* for salsa.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Sat, 19 May 2018 12:34:01 +0200
+
+wayland (1.15.0-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Put wayland-egl-backend.* to a separate dev-package.
+  * libwayland-egl1.symbols: Fixed.
+  * control: Bump Breaks/Replaces on libegl1-mesa-dev, so that this can
+    be synced to Ubuntu.
+
+ -- Timo Aaltonen <tjaalton@debian.org>  Wed, 18 Apr 2018 10:41:38 +0300
+
+wayland (1.14.93-1) experimental; urgency=medium
+
+  * New upstrem release candidate.
+
+ -- Timo Aaltonen <tjaalton@debian.org>  Tue, 03 Apr 2018 10:53:33 +0300
+
+wayland (1.14.92-1) experimental; urgency=medium
+
+  [ Timo Aaltonen ]
+  * New upstream pre-release.
+  * signing-keys.asc: Updated.
+  * libwayland-dev.install: Drop static libs, they're not provided
+    anymore.
+  * libwayland-egl1.symbols: Updated.
+  * control: Adjust Breaks/Provides for libwayland-egl migration.
+
+  [ Héctor Orón Martínez ]
+  * control: Fix uninstallability issues. (Closes: #893366)
+
+ -- Timo Aaltonen <tjaalton@debian.org>  Wed, 21 Mar 2018 21:42:58 +0200
+
+wayland (1.14.91-1) experimental; urgency=medium
+
+  [ Helmut Grohne ]
+  * Use wayland-scanner from libwayland-bin (Closes: #836687)
+    - Fixes cross builds
+
+  [ Héctor Orón Martínez ]
+  * New upstream pre-release
+  * debian/control: libwayland-dev suggests libwayland-doc (Closes: #857139)
+  * debian/libwayland-server0.symbols: update
+  * debian/control: update priority from extra to optional
+  * libwayland-egl1: add new package
+  * debian/control: bump standards version
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Tue, 13 Mar 2018 16:01:40 +0100
+
+wayland (1.14.0-2) unstable; urgency=medium
+
+  * debian/patches/CVE-2017-16612.patch: (Closes: #889681)
+    - libXcursor before 1.1.15 has various integer overflows that could lead
+      to heap buffer overflows when processing malicious cursors, e.g., with
+      programs like GIMP. It is also possible that an attack vector exists
+      against the related code in cursor/xcursor.c in Wayland through
+      1.14.0.
+  * switch back to use upstream tarball
+  * debian/control: bump standards version, drop priority stanzas
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Sun, 04 Mar 2018 11:56:31 +0100
+
+wayland (1.14.0-1) unstable; urgency=medium
+
+  * New upstream release.
+  * libwayland-{client,server}0.symbols: Updated.
+
+ -- Timo Aaltonen <tjaalton@debian.org>  Thu, 10 Aug 2017 11:09:15 +0300
+
+wayland (1.13.0-1) unstable; urgency=medium
+
+  * New upstream release. (Closes: #870566)
+  * libwayland-server0.symbols: Updated.
+
+ -- Timo Aaltonen <tjaalton@debian.org>  Thu, 03 Aug 2017 11:25:29 +0300
+
+wayland (1.12.0-1) unstable; urgency=medium
+
+  * New upstream release. Closes: #840752.
+  * Update various links to https.
+  * Verify upstream tarball signatures. Thanks Hideki Yamane.
+  * Bump debhelper compat to 10.
+    + debhelper now calls dh-autoreconf by default.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Wed, 07 Dec 2016 18:54:57 +0100
+
+wayland (1.11.94-1) experimental; urgency=medium
+
+  * New upstream pre-release.
+  * Standards-Version is 3.9.8, no changes needed.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Wed, 14 Sep 2016 12:10:19 +0200
+
+wayland (1.11.91-1) experimental; urgency=medium
+
+  * New upstream pre-release
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Thu, 18 Aug 2016 17:18:52 +0200
+
+wayland (1.11.0-2) unstable; urgency=medium
+
+  * d/control: libwayland-dev depends on libwayland-bin
+  * d/control: libwayland-bin replaces libwayland-dev
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Mon, 06 Jun 2016 11:28:46 +0200
+
+wayland (1.11.0-1) unstable; urgency=medium
+
+  * New upstream release
+  * d/control: make libwayland-dev multiarch aware
+    - based on a patch from Dima Kogan.
+    (Closes: #739400)
+  * d/libwayland-client0.symbols: update with new symbols
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Thu, 02 Jun 2016 11:37:00 +0200
+
+wayland (1.10.0-2) unstable; urgency=medium
+
+  * Don't build the documentation on binary-arch only builds. Move the
+    build-dependencies needed for the documentation to build-depends-indep.
+    Closes: #821170.
+  * Move the manpages to libwayland-doc.
+  * Switch to dbgsym packages.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Wed, 20 Apr 2016 21:38:58 +0200
+
+wayland (1.10.0-1) unstable; urgency=medium
+
+  * New upstream release
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Thu, 31 Mar 2016 13:13:12 +0200
+
+wayland (1.9.92-1) experimental; urgency=medium
+
+  * New upstream release, experimental upload.
+
+  [ Hideki Yamane ]
+  * debian/control
+    - add Build-Depends: libxml2-dev
+  * update debian/libwayland-{client,server}0.symbols
+  * update debian/watch (Closes: #813484)
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Thu, 04 Feb 2016 23:22:27 +0100
+
+wayland (1.9.0-1) unstable; urgency=medium
+
+  * New upstream release
+
+ -- Héctor Orón Martínez <zumbi@debian.org>  Sun, 27 Sep 2015 00:08:11 +0200
+
+wayland (1.8.1-1) unstable; urgency=medium
+
+  * New upstream release
+
+ -- Hector Oron <zumbi@debian.org>  Sat, 13 Jun 2015 02:00:30 +0200
+
+wayland (1.7.0-2) unstable; urgency=medium
+
+  * Remove Cyril from Uploaders. Thanks for your past work!
+  * Upload to unstable.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Wed, 27 May 2015 00:35:08 +0200
+
+wayland (1.7.0-1) experimental; urgency=medium
+
+  [ Timo Aaltonen ]
+  * New upstream release.
+  * control: Add xmlto and graphviz to build-depends to build the
+    new documentation.
+  * libwayland-doc: Add a new package for documentation files.
+
+  [ Hector Oron ]
+  * Upload to experimental.
+
+ -- Hector Oron <zumbi@debian.org>  Wed, 06 May 2015 12:35:23 +0200
+
+wayland (1.6.1-2) experimental; urgency=medium
+
+  * Rebuild against upstream tarball.
+
+ -- Hector Oron <zumbi@debian.org>  Sat, 24 Jan 2015 10:39:19 +0100
+
+wayland (1.6.1-1) experimental; urgency=medium
+
+  * New bugfix upstream release:
+    - documentation: fix several typoes.
+    - scanner, client: several improvements.
+    - tests: fix memory leak
+  * d/control: update VCS URL
+  * d/control: bump standards version, no changes needed.
+
+ -- Hector Oron <zumbi@debian.org>  Wed, 24 Sep 2014 01:01:26 +0200
+
+wayland (1.6.0-2) unstable; urgency=medium
+
+  * Switch back to use upstream tarball.
+
+ -- Hector Oron <zumbi@debian.org>  Tue, 23 Sep 2014 18:09:53 +0200
+
+wayland (1.6.0-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Hector Oron <zumbi@debian.org>  Fri, 19 Sep 2014 16:28:13 +0200
+
+wayland (1.5.93-2) unstable; urgency=medium
+
+  * Upload to unstable.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Tue, 16 Sep 2014 22:42:06 +0200
+
+wayland (1.5.93-1) experimental; urgency=medium
+
+  * New upstream development release.
+  * Upload to experimental.
+
+ -- Hector Oron <zumbi@debian.org>  Fri, 12 Sep 2014 16:17:43 +0200
+
+wayland (1.5.91-1) experimental; urgency=medium
+
+  [ Andreas Henriksson ]
+  * New upstream development release.
+  * Update debian/libwayland-client0.symbols with two additions
+  * Update debian/libwayland-server0.symbols with one addition
+
+  [ Emilio Pozuelo Monfort ]
+  * Upload to experimental.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Fri, 05 Sep 2014 03:10:22 +0200
+
+wayland (1.5.0-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Switch back to source format 1.0 for now.
+  * debian/libwayland-dev.install:
+    + Update path for wayland-scanner.pc.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Sat, 24 May 2014 02:54:40 +0200
+
+wayland (1.4.0-1) unstable; urgency=medium
+
+  * New upstream release 1.4.0:
+    - SHM Buffer SIBGUS protection.
+    - Subsurfaces protocol moved to wayland repo and promoted to official
+      wayland protocol
+    - wl_proxy_set_queue() can take a NULL queue to reset back to default
+      queue.
+    - Fix race between wl_proxy_create() and wl_proxy_marshal()
+    - scanner error message improvements and documentation improvements
+  * d/control: Further bump the libwayland0 C/R to cover Collabora version.
+    Thanks Peter Green for patch.
+    (Closes: #731607)
+  * d/control: update standards version
+
+ -- Hector Oron <zumbi@debian.org>  Thu, 30 Jan 2014 23:49:42 +0100
+
+wayland (1.3.92-1) unstable; urgency=medium
+
+  * New upstream release (1.3.92)
+  * d/libwayland-dev.install:
+     - add wayland DTD and XML under default dtddir.
+
+ -- Hector Oron <zumbi@debian.org>  Sat, 18 Jan 2014 18:16:17 +0100
+
+wayland (1.3.0-1) unstable; urgency=low
+
+  [ Timo Aaltonen ]
+  * control: Bump the libwayland0 C/R to (<< 1.1.0) so that it covers
+    the ubuntu version too, and add it to -cursor.
+
+  [ Hector Oron ]
+  * New upstream stable release (1.3.0).
+  * Add myself to Uploaders.
+  * Switch to Debian source format 3.0 quilt.
+  * d/libwayland-dev.install:
+    - install wayland documentation
+
+ -- Hector Oron <zumbi@debian.org>  Fri, 11 Oct 2013 11:23:38 +0200
+
+wayland (1.2.1-1) unstable; urgency=low
+
+  [ Sven Joachim ]
+  * New upstream release (1.2.0).
+  * Update symbols files and bump shlibs of libwayland-{client,server}0.
+    - ABI break: libwayland-server0 removed several symbols used by
+      weston releases prior to 1.2, add a Breaks to accommodate that.
+
+  [ Emilio Pozuelo Monfort ]
+  * New upstream stable release (1.2.1).
+  * Add myself to Uploaders.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Sun, 08 Sep 2013 19:46:04 +0200
+
+wayland (1.1.0-2) unstable; urgency=low
+
+  * Team upload.
+  * Upload to unstable.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Thu, 06 Jun 2013 23:22:34 +0200
+
+wayland (1.1.0-1) experimental; urgency=low
+
+  * Team upload.
+  * New upstream release.
+  * debian/libwayland-client0.symbols
+    debian/libwayland-server0.symbols:
+    + Add a couple of new symbols.
+  * debian/rules:
+    + Bump SHVER accordingly.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Mon, 03 Jun 2013 08:44:14 +0200
+
+wayland (1.0.5-2) experimental; urgency=low
+
+  * Team upload.
+  * Add missing conflict/replaces for the library split.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Tue, 21 May 2013 09:39:01 +0200
+
+wayland (1.0.5-1) experimental; urgency=low
+
+  * Team upload.
+
+  [ Robert Ancell ]
+  * debian/libwayland-dev.install:
+    - Install development man pages
+  * debian/control:
+    - Build-depend on doxygen
+    - Build-depend on xsltproc
+
+  [ Timo Aaltonen ]
+  * New upstream release.
+  * Migrate to multiarch (Closes: #690081).
+  * copyright: Refresh.
+  * control: Update Standards-Version to 3.9.4, no changes.
+  * rules: Make it non-fatal to fail the tests, which don't all succeed
+    when ran in headless mode.
+  * rules: Drop the creation of hard dependencies, wayland should be
+    mostly API stable now.
+  * rules: Drop dh_auto_install override.  dh_auto_install automatically
+    installs to debian/tmp whenever there are multiple binary packages.
+  * libwayland*.install: Add missing files.
+  * rules: Temporarily disable installing the protocol docs, decide where
+    to put them first.
+  * Add README.source
+
+  [ Sven Joachim ]
+  * Update symbols file, bumping minver of all symbols to at least 1.0.2.
+  * Add docbook-xsl to Build-Depends.
+  * Add Homepage field to debian/control.
+  * Update debian/copyright.
+
+  [ Emilio Pozuelo Monfort ]
+  * Split the shared libraries into separate packages.
+  * Add Build-Depends-Package to symbol files.
+
+ -- Emilio Pozuelo Monfort <pochu@debian.org>  Tue, 21 May 2013 00:34:22 +0200
+
+wayland (0.85.0-2) unstable; urgency=low
+
+  * Upload to unstable.
+  * Wayland/Weston aren't quite ready to replace Xorg yet, but let's
+    upload those to unstable anyway, so that people can find out by
+    themselves. On the plus side, mesa can stop getting wayland support
+    enabled in experimental, then disabled back when uploaded to unstable.
+  * Update long description, wayland-demos got replaced by weston.
+
+ -- Cyril Brulebois <kibi@debian.org>  Sun, 29 Apr 2012 22:34:18 +0200
+
+wayland (0.85.0-1) experimental; urgency=low
+
+  * First upstream release:
+    - http://article.gmane.org/gmane.comp.freedesktop.wayland.devel/1770
+  * Update watch file, even if that's only useful for notifications:
+    upstream releases xz tarballs, and the 1.0 source format only suports
+    gz.
+
+ -- Cyril Brulebois <kibi@debian.org>  Fri, 10 Feb 2012 11:51:36 +0100
+
+wayland (0.1.0~2-1) experimental; urgency=low
+
+  * New upstream snapshot.
+  * Update symbols file.
+
+ -- Cyril Brulebois <kibi@debian.org>  Mon, 30 Jan 2012 22:37:54 +0100
+
+wayland (0.1.0~1-1) experimental; urgency=low
+
+  * New upstream snapshot.
+  * Update symbols file.
+
+ -- Cyril Brulebois <kibi@debian.org>  Fri, 23 Dec 2011 14:45:10 +0100
+
+wayland (0.1.0~0-1) experimental; urgency=low
+
+  * Initial release (Closes: #611400).
+  * debian/rules contains a gentarball target to create a tarball from the
+    upstream-experimental branch, to be used until some upstream release
+    happens.
+
+ -- Cyril Brulebois <kibi@debian.org>  Sat, 18 Jun 2011 13:38:40 +0200
--- wayland-1.21.0.orig/debian/compat
+++ wayland-1.21.0/debian/compat
@@ -0,0 +1 @@
+10
--- wayland-1.21.0.orig/debian/control
+++ wayland-1.21.0/debian/control
@@ -0,0 +1,174 @@
+Source: wayland
+Section: x11
+Priority: optional
+Uploaders: Emilio Pozuelo Monfort <pochu@debian.org>,
+           Héctor Orón Martínez <zumbi@debian.org>
+Build-Depends: debhelper (>= 10),
+               libexpat1-dev,
+               libffi-dev,
+               libwayland-bin <cross>,
+               libxml2-dev,
+               meson,
+               pkg-config,
+               quilt
+Build-Depends-Indep: docbook-xsl, doxygen, graphviz, xmlto, xsltproc
+Standards-Version: 4.5.0
+Homepage: https://wayland.freedesktop.org/
+Vcs-Git: https://invent.kde.org/neon/backports-focal/wayland.git
+Vcs-Browser: https://invent.kde.org/neon/backports-focal/wayland
+Maintainer: Neon CI <neon@kde.org>
+
+Package: libwayland-client0
+Section: libs
+Architecture: any
+Pre-Depends: ${misc:Pre-Depends}
+Multi-Arch: same
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Conflicts: libwayland0 (<< 1.1.0-1)
+Replaces: libwayland0 (<< 1.1.0-1)
+Description: wayland compositor infrastructure - client library
+ Wayland is a protocol for a compositor to talk to its clients as well
+ as a C library implementation of that protocol. The compositor can be
+ a standalone display server running on Linux kernel modesetting and
+ evdev input devices, an X application, or a wayland client
+ itself. The clients can be traditional applications, X servers
+ (rootless or fullscreen) or other display servers.
+ .
+ This package ships the library that implements the client side of
+ the Wayland protocol.
+
+Package: libwayland-egl1
+Section: libs
+Architecture: any
+Pre-Depends: ${misc:Pre-Depends}
+Multi-Arch: same
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Breaks: libwayland-egl1-mesa (<< 18.0.5-0)
+Replaces: libwayland-egl1-mesa (<< 18.0.5-0)
+Provides: libwayland-egl1-mesa
+Description: wayland compositor infrastructure - EGL library
+ Wayland is a protocol for a compositor to talk to its clients as well
+ as a C library implementation of that protocol. The compositor can be
+ a standalone display server running on Linux kernel modesetting and
+ evdev input devices, an X application, or a wayland client
+ itself. The clients can be traditional applications, X servers
+ (rootless or fullscreen) or other display servers.
+ .
+ This package ships the library that implements the Wayland EGL platform
+ of the Wayland protocol.
+
+Package: libwayland-server0
+Section: libs
+Architecture: any
+Pre-Depends: ${misc:Pre-Depends}
+Multi-Arch: same
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Conflicts: libwayland0 (<< 1.1.0-1)
+Replaces: libwayland0 (<< 1.1.0-1)
+Breaks: weston (<< 1.2.0)
+Description: wayland compositor infrastructure - server library
+ Wayland is a protocol for a compositor to talk to its clients as well
+ as a C library implementation of that protocol. The compositor can be
+ a standalone display server running on Linux kernel modesetting and
+ evdev input devices, an X application, or a wayland client
+ itself. The clients can be traditional applications, X servers
+ (rootless or fullscreen) or other display servers.
+ .
+ This package ships the library that implements the server side of
+ the Wayland protocol.
+
+Package: libwayland-cursor0
+Section: libs
+Architecture: any
+Pre-Depends: ${misc:Pre-Depends}
+Multi-Arch: same
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Conflicts: libwayland0 (<< 1.1.0-1)
+Replaces: libwayland0 (<< 1.1.0-1)
+Description: wayland compositor infrastructure - cursor library
+ Wayland is a protocol for a compositor to talk to its clients as well
+ as a C library implementation of that protocol. The compositor can be
+ a standalone display server running on Linux kernel modesetting and
+ evdev input devices, an X application, or a wayland client
+ itself. The clients can be traditional applications, X servers
+ (rootless or fullscreen) or other display servers.
+ .
+ This package ships a helper library to manage cursors.
+
+Package: libwayland-dev
+Section: libdevel
+Architecture: any
+Suggests: libwayland-doc
+Depends: libffi-dev,
+         libwayland-bin (= ${binary:Version}),
+         libwayland-client0 (= ${binary:Version}),
+         libwayland-cursor0 (= ${binary:Version}),
+         libwayland-egl1 (= ${binary:Version}),
+         libwayland-server0 (= ${binary:Version}),
+         ${misc:Depends},
+         ${shlibs:Depends}
+Breaks: libegl1-mesa-dev (<< 18.0.5-0)
+Replaces: libegl1-mesa-dev (<< 18.0.5-0)
+Multi-Arch: same
+Description: wayland compositor infrastructure - development files
+ Wayland is a protocol for a compositor to talk to its clients as well
+ as a C library implementation of that protocol. The compositor can be
+ a standalone display server running on Linux kernel modesetting and
+ evdev input devices, an X application, or a wayland client
+ itself. The clients can be traditional applications, X servers
+ (rootless or fullscreen) or other display servers.
+ .
+ This package contains the development headers for the Wayland libraries.
+ Non-developers likely have little use for this package.
+
+Package: libwayland-egl-backend-dev
+Section: libdevel
+Architecture: any
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Breaks: libegl1-mesa-dev (<< 18.0.5-0), libwayland-dev (<< 1.15.0)
+Replaces: libegl1-mesa-dev (<< 18.0.5-0), libwayland-dev (<< 1.15.0)
+Multi-Arch: same
+Description: wayland compositor infrastructure - EGL backend development files
+ Wayland is a protocol for a compositor to talk to its clients as well
+ as a C library implementation of that protocol. The compositor can be
+ a standalone display server running on Linux kernel modesetting and
+ evdev input devices, an X application, or a wayland client
+ itself. The clients can be traditional applications, X servers
+ (rootless or fullscreen) or other display servers.
+ .
+ This package contains the development headers for the Wayland EGL backend.
+
+Package: libwayland-doc
+Section: doc
+Architecture: all
+Depends: ${misc:Depends}
+Multi-Arch: foreign
+Conflicts: libwayland-dev (<< 1.10.0-2)
+Replaces: libwayland-dev (<< 1.10.0-2)
+Description: wayland compositor infrastructure - documentation files
+ Wayland is a protocol for a compositor to talk to its clients as well
+ as a C library implementation of that protocol. The compositor can be
+ a standalone display server running on Linux kernel modesetting and
+ evdev input devices, an X application, or a wayland client
+ itself. The clients can be traditional applications, X servers
+ (rootless or fullscreen) or other display servers.
+ .
+ This package contains the documentation for the Wayland libraries.
+ Non-developers likely have little use for this package.
+
+Package: libwayland-bin
+Section: libdevel
+Architecture: any
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Conflicts: libwayland-dev (<< 1.11.0-1)
+Replaces: libwayland-dev (<< 1.11.0-1)
+Multi-Arch: foreign
+Description: wayland compositor infrastructure - binary utilities
+ Wayland is a protocol for a compositor to talk to its clients as well
+ as a C library implementation of that protocol. The compositor can be
+ a standalone display server running on Linux kernel modesetting and
+ evdev input devices, an X application, or a wayland client
+ itself. The clients can be traditional applications, X servers
+ (rootless or fullscreen) or other display servers.
+ .
+ This package contains the development binary utilities
--- wayland-1.21.0.orig/debian/copyright
+++ wayland-1.21.0/debian/copyright
@@ -0,0 +1,54 @@
+Upstream-Name: wayland
+Upstream-Contact: Kristian Høgsberg <krh@bitplanet.net>
+Source: https://wayland.freedesktop.org/releases/
+
+Files: debian/*
+Copyright: © 2011 Cyril Brulebois <kibi@debian.org>
+License: X11
+
+Files: *
+Copyright:
+ © 1999 SuSE, Inc.
+ © 2002 Keith Packard
+ © 2006, 2008 Junio C Hamano
+ © 2008-2012 Kristian Høgsberg
+ © 2010-2012 Intel Corporation
+ © 2011 Benjamin Franzke
+ © 2012-2013, 2016 Collabora, Ltd
+ © 2012-2013 Jason Ekstrand
+ © 2012-2014 Jonas Ådahl
+ © 2013 Marek Chalupa
+ © 2014-2015 Red Hat, Inc.
+ © 2015 Giulio Camuffo
+ © 2016 Klarälvdalens Datakonsult AB
+ © 2016 Yong Bakos
+ © 2017 NVIDIA CORPORATION
+ © 2017 Samsung Electronics Co., Ltd
+License: X11
+
+License: X11
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ .
+  ---
+ .
+ The above is the version of the MIT "Expat" License used by X.org:
+ .
+     http://cgit.freedesktop.org/xorg/xserver/tree/COPYING
+
--- wayland-1.21.0.orig/debian/libwayland-bin.install
+++ wayland-1.21.0/debian/libwayland-bin.install
@@ -0,0 +1,4 @@
+# Tool to build various other packages:
+usr/bin/wayland-scanner
+usr/share/aclocal/wayland-scanner.m4
+usr/share/wayland/wayland-scanner.mk
--- wayland-1.21.0.orig/debian/libwayland-client0.install
+++ wayland-1.21.0/debian/libwayland-client0.install
@@ -0,0 +1,2 @@
+# Be careful with wildcards to ensure we spot any ABI bump:
+usr/lib/*/libwayland-client.so.0*
--- wayland-1.21.0.orig/debian/libwayland-cursor0.install
+++ wayland-1.21.0/debian/libwayland-cursor0.install
@@ -0,0 +1,2 @@
+# Be careful with wildcards to ensure we spot any ABI bump:
+usr/lib/*/libwayland-cursor.so.0*
--- wayland-1.21.0.orig/debian/libwayland-dev.install
+++ wayland-1.21.0/debian/libwayland-dev.install
@@ -0,0 +1,23 @@
+# Headers:
+usr/include/wayland-client*
+usr/include/wayland-cursor.h
+usr/include/wayland-egl.h
+usr/include/wayland-egl-core.h
+usr/include/wayland-server*
+usr/include/wayland-util.h
+usr/include/wayland-version.h
+
+# Use no wildcards to ensure we spot any update:
+usr/lib/*/libwayland-client.so
+usr/lib/*/libwayland-cursor.so
+usr/lib/*/libwayland-egl.so
+usr/lib/*/libwayland-server.so
+usr/lib/*/pkgconfig/wayland-client.pc
+usr/lib/*/pkgconfig/wayland-cursor.pc
+usr/lib/*/pkgconfig/wayland-egl.pc
+usr/lib/*/pkgconfig/wayland-server.pc
+usr/lib/*/pkgconfig/wayland-scanner.pc
+
+# Documentation
+usr/share/wayland/wayland.xml
+usr/share/wayland/wayland.dtd
--- wayland-1.21.0.orig/debian/libwayland-doc.install
+++ wayland-1.21.0/debian/libwayland-doc.install
@@ -0,0 +1,4 @@
+usr/share/doc/wayland/Wayland/en-US/html/
+
+# Man pages
+usr/share/man/man3
--- wayland-1.21.0.orig/debian/libwayland-egl-backend-dev.install
+++ wayland-1.21.0/debian/libwayland-egl-backend-dev.install
@@ -0,0 +1,2 @@
+usr/include/wayland-egl-backend.h
+usr/lib/*/pkgconfig/wayland-egl-backend.pc
--- wayland-1.21.0.orig/debian/libwayland-egl1.install
+++ wayland-1.21.0/debian/libwayland-egl1.install
@@ -0,0 +1,2 @@
+# Be careful with wildcards to ensure we spot any ABI bump:
+usr/lib/*/libwayland-egl.so.1*
--- wayland-1.21.0.orig/debian/libwayland-server0.install
+++ wayland-1.21.0/debian/libwayland-server0.install
@@ -0,0 +1,2 @@
+# Be careful with wildcards to ensure we spot any ABI bump:
+usr/lib/*/libwayland-server.so.0*
--- wayland-1.21.0.orig/debian/patches/meson-no-cross-compile.diff
+++ wayland-1.21.0/debian/patches/meson-no-cross-compile.diff
@@ -0,0 +1,19 @@
+Index: wayland-1.20.0/src/meson.build
+===================================================================
+diff --git a/.pc/patchy/src/meson.build b/src/meson.build
+index ae8f387..3fcbf6b 100644
+--- a/.pc/patchy/src/meson.build
++++ b/src/meson.build
+@@ -69,12 +69,7 @@ if get_option('scanner')
+ 	)
+ endif
+ 
+-if meson.is_cross_build() or not get_option('scanner')
+-	scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())
+-	wayland_scanner_for_build = find_program(scanner_dep.get_pkgconfig_variable('wayland_scanner'))
+-else
+ 	wayland_scanner_for_build = wayland_scanner
+-endif
+ 
+ if get_option('libraries')
+ 	# wayland libraries
--- wayland-1.21.0.orig/debian/patches/series
+++ wayland-1.21.0/debian/patches/series
@@ -0,0 +1 @@
+meson-no-cross-compile.diff
--- wayland-1.21.0.orig/debian/rules
+++ wayland-1.21.0/debian/rules
@@ -0,0 +1,45 @@
+#!/usr/bin/make -f
+
+SOURCE=wayland
+
+# Don't build the documentation when not building arch:all packages
+ifeq (,$(filter libwayland-doc,$(shell dh_listpackages)))
+configure_flags += -Ddocumentation=false
+endif
+
+override_dh_auto_configure:
+	dh_auto_configure -- $(configure_flags)
+
+# Kill *.la files, and forget no-one:
+override_dh_install:
+	find debian/tmp -name '*.la' -delete
+	dh_install --fail-missing
+
+override_dh_makeshlibs:
+	dh_makeshlibs -plibwayland-client0 \
+		-V 'libwayland-client0 (>= 1.2.0)' -- -c4
+	dh_makeshlibs -plibwayland-cursor0 \
+		-V 'libwayland-cursor0 (>= 1.0.4)' -- -c4
+	dh_makeshlibs -plibwayland-egl1 \
+		-V 'libwayland-egl1 (>= 1.14.91)' -- -c4
+	dh_makeshlibs -plibwayland-server0 \
+		-V 'libwayland-server0 (>= 1.2.0)' -- -c4
+
+# Debug package:
+override_dh_strip:
+	dh_strip -plibwayland-client0 --dbgsym-migration='libwayland-client0 (<< 1.10.0-2)'
+	dh_strip -plibwayland-cursor0 --dbgsym-migration='libwayland-cursor0 (<< 1.10.0-2)'
+	dh_strip -plibwayland-server0 --dbgsym-migration='libwayland-server0 (<< 1.10.0-2)'
+	dh_strip -a --remaining-packages
+
+override_dh_auto_test:
+	# the test suite does not pass completely in headless mode
+	dh_auto_test || true
+
+%:
+	dh $@ --with quilt --builddirectory=build/ --buildsystem=meson
+
+# For maintainer use only, generate a tarball:
+gentarball: UV=$(shell dpkg-parsechangelog|awk '/^Version:/ {print $$2}'|sed 's/-.*$$//')
+gentarball:
+	git archive --format=tar upstream-experimental --prefix=$(SOURCE)-$(UV)/ | gzip -9 > ../$(SOURCE)_$(UV).orig.tar.gz
--- wayland-1.21.0.orig/debian/upstream/signing-key.asc
+++ wayland-1.21.0/debian/upstream/signing-key.asc
@@ -0,0 +1,178 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+
[encoded data, 11418 characters]
+kaaLvgP9RadLPb9NQGEqPHS2cohkvg==
+=dLLR
+-----END PGP PUBLIC KEY BLOCK-----
--- wayland-1.21.0.orig/debian/watch
+++ wayland-1.21.0/debian/watch
@@ -0,0 +1,4 @@
+#git=git://anongit.freedesktop.org/wayland/wayland
+version=4
+opts="pgpsigurlmangle=s%$%.sig%" \
+https://wayland.freedesktop.org/releases.html https://gitlab.freedesktop.org/wayland/wayland/-/releases/[\d].*/downloads/wayland-([\d].*).tar.xz
--- wayland-1.21.0.orig/doc/doxygen/meson.build
+++ wayland-1.21.0/doc/doxygen/meson.build
@@ -13,7 +13,7 @@
 
 doxygen_conf = configuration_data()
 doxygen_conf.set('VERSION', meson.project_version())
-doxygen_conf.set('top_builddir', meson.project_build_root())
+doxygen_conf.set('top_builddir', meson.build_root())
 wayland_doxygen = configure_file(
 	input: 'wayland.doxygen.in',
 	output: 'wayland.doxygen',
@@ -76,7 +76,6 @@
 		# We do not really need an output file, but Meson
 		# will complain if one is not set, so we use a
 		# dummy 'stamp' file
-		stamp = join_paths(meson.current_build_dir(), '@0@.stamp'.format(t_name))
 		custom_target(
 			t_name,
 			command: [
@@ -85,7 +84,7 @@
 				'--builddir=@OUTDIR@',
 				'--section=@0@'.format(s_name),
 				'--output-format=@0@'.format(f_name),
-				'--stamp=@0@'.format(stamp),
+				'--stamp=doc/doxygen/@0@.stamp'.format(t_name),
 				wayland_doxygen,
 				'@INPUT@',
 			],
@@ -98,14 +97,13 @@
 endforeach
 
 man_files = shared_files + server_files + client_files + cursor_files
-stamp = join_paths(meson.current_build_dir(), 'man3.stamp')
 custom_target(
 	'man-pages-3',
 	command: [
 		gen_doxygen,
 		'--builddir=@OUTDIR@',
 		'--output-format=man3',
-		'--stamp=@0@'.format(stamp),
+		'--stamp=doc/doxygen/man3.stamp',
 		wayland_doxygen,
 		'@INPUT@',
 	],
--- wayland-1.21.0.orig/doc/meson.build
+++ wayland-1.21.0/doc/meson.build
@@ -1,7 +1,3 @@
-if not get_option('libraries')
-	error('-Ddocumentation=true requires -Dlibraries=true')
-endif
-
 dot = find_program('dot')
 doxygen = find_program('doxygen')
 xsltproc = find_program('xsltproc')
@@ -22,7 +18,7 @@
 endif
 
 manpage_xsl = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
-cmd = run_command(xsltproc, '--nonet', manpage_xsl, check: false)
+cmd = run_command(xsltproc, '--nonet', manpage_xsl)
 if cmd.returncode() != 0
 	error('The style sheet for man pages providing "@0@" was not found.'.format(manpage_xsl))
 endif
--- wayland-1.21.0.orig/doc/publican/meson.build
+++ wayland-1.21.0/doc/publican/meson.build
@@ -7,7 +7,6 @@
 	command: [
 		xmlto,
 		'--skip-validation',
-		'--stringparam', 'chunker.output.encoding=UTF-8',
 		'--stringparam', 'chunk.section.depth=0',
 		'--stringparam', 'toc.section.depth=1',
 		'--stringparam', 'generate.consistent.ids=1',
--- wayland-1.21.0.orig/doc/publican/sources/Protocol.xml
+++ wayland-1.21.0/doc/publican/sources/Protocol.xml
@@ -149,9 +149,9 @@
 	  <term>string</term>
 	  <listitem>
 	    <para>
-	      Starts with an unsigned 32-bit length (including null terminator),
-	      followed by the string contents, including terminating null byte,
-	      then padding to a 32-bit boundary.
+	      Starts with an unsigned 32-bit length, followed by the
+	      string contents, including terminating null byte, then padding
+	      to a 32-bit boundary.
 	    </para>
 	  </listitem>
 	</varlistentry>
@@ -194,21 +194,6 @@
 	</varlistentry>
       </variablelist>
     </para>
-    <para>
-      The protocol does not specify the exact position of the ancillary data
-      in the stream, except that the order of file descriptors is the same as
-      the order of messages and <code>fd</code> arguments within messages on
-      the wire.
-    </para>
-    <para>
-      In particular, it means that any byte of the stream, even the message
-      header, may carry the ancillary data with file descriptors.
-    </para>
-    <para>
-      Clients and compositors should queue incoming data until they have
-      whole messages to process, as file descriptors may arrive earlier
-      or later than the corresponding data bytes.
-    </para>
   </section>
   <xi:include href="ProtocolInterfaces.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
   <section id="sect-Protocol-Versioning">
--- wayland-1.21.0.orig/egl/meson.build
+++ wayland-1.21.0/egl/meson.build
@@ -11,7 +11,7 @@
 
 executable('wayland-egl-abi-check', 'wayland-egl-abi-check.c')
 
-nm_path = find_program('nm').full_path()
+nm_path = find_program('nm').path()
 
 test(
 	'wayland-egl symbols check',
--- wayland-1.21.0.orig/meson.build
+++ wayland-1.21.0/meson.build
@@ -1,12 +1,11 @@
 project(
 	'wayland', 'c',
-	version: '1.21.0',
+	version: '1.20.0',
 	license: 'MIT',
-	meson_version: '>= 0.56.0',
+	meson_version: '>= 0.52.1',
 	default_options: [
 		'warning_level=2',
-		'buildtype=debugoptimized',
-		'c_std=c99',
+		'buildtype=debugoptimized'
 	]
 )
 wayland_version = meson.project_version().split('.')
@@ -15,12 +14,6 @@
 config_h.set_quoted('PACKAGE', meson.project_name())
 config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
 
-cc_args = []
-if host_machine.system() != 'freebsd'
-	cc_args += ['-D_POSIX_C_SOURCE=200809L']
-endif
-add_project_arguments(cc_args, language: 'c')
-
 compiler_flags = [
 	'-Wno-unused-parameter',
 	'-Wstrict-prototypes',
@@ -86,7 +79,7 @@
 	]
 
 	foreach d: decls
-		if not cc.has_header_symbol(d['header'], d['symbol'], dependencies: epoll_dep, args: cc_args)
+		if not cc.has_header_symbol(d['header'], d['symbol'], dependencies: epoll_dep)
 			error('@0@ is needed to compile Wayland libraries'.format(d['symbol']))
 		endif
 	endforeach
@@ -94,7 +87,7 @@
 	rt_dep = []
 	if not cc.has_function('clock_gettime', prefix: '#include <time.h>')
 		rt_dep = cc.find_library('rt')
-		if not cc.has_function('clock_gettime', prefix: '#include <time.h>', dependencies: rt_dep, args: cc_args)
+		if not cc.has_function('clock_gettime', prefix: '#include <time.h>', dependencies: rt_dep)
 			error('clock_gettime not found')
 		endif
 	endif
@@ -118,12 +111,12 @@
 if get_option('libraries')
 	subdir('cursor')
 	subdir('egl')
-endif
-if get_option('tests')
-	subdir('tests')
-endif
-if get_option('documentation')
-	subdir('doc')
+	if get_option('tests')
+		subdir('tests')
+	endif
+	if get_option('documentation')
+		subdir('doc')
+	endif
 endif
 
 if get_option('scanner')
--- wayland-1.21.0.orig/meson_options.txt
+++ wayland-1.21.0/meson_options.txt
@@ -1,23 +1,23 @@
 option('libraries',
   description: 'Compile Wayland libraries',
   type: 'boolean',
-  value: true)
+  value: 'true')
 option('scanner',
   description: 'Compile wayland-scanner binary',
   type: 'boolean',
-  value: true)
+  value: 'true')
 option('tests',
   description: 'Compile Wayland tests',
   type: 'boolean',
-  value: true)
+  value: 'true')
 option('documentation',
   description: 'Build the documentation (requires Doxygen, dot, xmlto, xsltproc)',
   type: 'boolean',
-  value: true)
+  value: 'true')
 option('dtd_validation',
   description: 'Validate the protocol DTD (requires libxml2)',
   type: 'boolean',
-  value: true)
+  value: 'true')
 option('icon_directory',
   description: 'Location used to look for cursors (defaults to ${datadir}/icons if unset)',
   type: 'string',
--- wayland-1.21.0.orig/protocol/wayland.xml
+++ wayland-1.21.0/protocol/wayland.xml
@@ -258,12 +258,6 @@
 	for the pool from the file descriptor passed when the pool was
 	created, but using the new size.  This request can only be
 	used to make the pool bigger.
-
-        This request only changes the amount of bytes that are mmapped
-        by the server and does not touch the file corresponding to the
-        file descriptor passed at creation time. It is the client's
-        responsibility to ensure that the file is at least as big as
-        the new pool size.
       </description>
       <arg name="size" type="int" summary="new size of the pool, in bytes"/>
     </request>
@@ -277,8 +271,8 @@
       Clients can create wl_shm_pool objects using the create_pool
       request.
 
-      On binding the wl_shm object one or more format events
-      are emitted to inform clients about the valid pixel formats
+      At connection setup time, the wl_shm object emits one or more
+      format events to inform clients about the valid pixel formats
       that can be used for buffers.
     </description>
 
@@ -896,7 +890,7 @@
 	which will subsequently be used in either the
 	data_device.enter event (for drag-and-drop) or the
 	data_device.selection event (for selections).  Immediately
-	following the data_device.data_offer event, the new data_offer
+	following the data_device_data_offer event, the new data_offer
 	object will send out data_offer.offer events to describe the
 	mime types it offers.
       </description>
@@ -1057,8 +1051,7 @@
       a basic surface.
 
       Note! This protocol is deprecated and not intended for production use.
-      For desktop-style user interfaces, use xdg_shell. Compositors and clients
-      should not implement this interface.
+      For desktop-style user interfaces, use xdg_shell.
     </description>
 
     <enum name="error">
@@ -1788,7 +1781,7 @@
     </request>
    </interface>
 
-  <interface name="wl_seat" version="8">
+  <interface name="wl_seat" version="7">
     <description summary="group of input devices">
       A seat is a group of keyboards, pointer and touch devices. This
       object is published as a global during start up, or when such a
@@ -1921,7 +1914,7 @@
 
   </interface>
 
-  <interface name="wl_pointer" version="8">
+  <interface name="wl_pointer" version="7">
     <description summary="pointer input device">
       The wl_pointer interface represents one or more input devices,
       such as mice, which control the pointer location and pointer_focus
@@ -2221,9 +2214,6 @@
 	This event carries the axis value of the wl_pointer.axis event in
 	discrete steps (e.g. mouse wheel clicks).
 
-	This event is deprecated with wl_pointer version 8 - this event is not
-	sent to clients supporting version 8 or later.
-
 	This event does not occur on its own, it is coupled with a
 	wl_pointer.axis event that represents this axis value on a
 	continuous scale. The protocol guarantees that each axis_discrete
@@ -2231,8 +2221,7 @@
 	axis number within the same wl_pointer.frame. Note that the protocol
 	allows for other events to occur between the axis_discrete and
 	its coupled axis event, including other axis_discrete or axis
-	events. A wl_pointer.frame must not contain more than one axis_discrete
-	event per axis type.
+	events.
 
 	This event is optional; continuous scrolling devices
 	like two-finger scrolling on touchpads do not have discrete
@@ -2250,37 +2239,9 @@
       <arg name="axis" type="uint" enum="axis" summary="axis type"/>
       <arg name="discrete" type="int" summary="number of steps"/>
     </event>
-
-    <event name="axis_value120" since="8">
-      <description summary="axis high-resolution scroll event">
-	Discrete high-resolution scroll information.
-
-	This event carries high-resolution wheel scroll information,
-	with each multiple of 120 representing one logical scroll step
-	(a wheel detent). For example, an axis_value120 of 30 is one quarter of
-	a logical scroll step in the positive direction, a value120 of
-	-240 are two logical scroll steps in the negative direction within the
-	same hardware event.
-	Clients that rely on discrete scrolling should accumulate the
-	value120 to multiples of 120 before processing the event.
-
-	The value120 must not be zero.
-
-	This event replaces the wl_pointer.axis_discrete event in clients
-	supporting wl_pointer version 8 or later.
-
-	Where a wl_pointer.axis_source event occurs in the same
-	wl_pointer.frame, the axis source applies to this event.
-
-	The order of wl_pointer.axis_value120 and wl_pointer.axis_source is
-	not guaranteed.
-      </description>
-      <arg name="axis" type="uint" enum="axis" summary="axis type"/>
-      <arg name="value120" type="int" summary="scroll distance as fraction of 120"/>
-    </event>
   </interface>
 
-  <interface name="wl_keyboard" version="8">
+  <interface name="wl_keyboard" version="7">
     <description summary="keyboard input device">
       The wl_keyboard interface represents one or more keyboards
       associated with a seat.
@@ -2294,7 +2255,7 @@
       <entry name="no_keymap" value="0"
 	     summary="no keymap; client must understand how to interpret the raw keycode"/>
       <entry name="xkb_v1" value="1"
-	     summary="libxkbcommon compatible, null-terminated string; to determine the xkb keycode, clients must add 8 to the key event keycode"/>
+	     summary="libxkbcommon compatible; to determine the xkb keycode, clients must add 8 to the key event keycode"/>
     </enum>
 
     <event name="keymap">
@@ -2407,7 +2368,7 @@
     </event>
   </interface>
 
-  <interface name="wl_touch" version="8">
+  <interface name="wl_touch" version="7">
     <description summary="touchscreen input device">
       The wl_touch interface represents a touchscreen
       associated with a seat.
--- wayland-1.21.0.orig/publish-doc
+++ wayland-1.21.0/publish-doc
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+
+[ -e doc ] || (echo "Run this from the project root" && exit 1)
+
+make
+
+DOC_HTML=./doc/publican/Wayland/en-US/html/
+
+[ -e "${DOC_HTML}" ] || (echo "HTML documentation failed to build at ${DOC_HTML}" && exit 1)
+
+chmod -R g+x ${DOC_HTML}
+
+rsync --delete -avz ${DOC_HTML} freedesktop.org:/srv/wayland.freedesktop.org/www/docs/html/
--- wayland-1.21.0.orig/src/connection.c
+++ wayland-1.21.0/src/connection.c
@@ -231,7 +231,7 @@
 }
 
 static void
-build_cmsg(struct wl_ring_buffer *buffer, char *data, size_t *clen)
+build_cmsg(struct wl_ring_buffer *buffer, char *data, int *clen)
 {
 	struct cmsghdr *cmsg;
 	size_t size;
@@ -289,10 +289,9 @@
 wl_connection_flush(struct wl_connection *connection)
 {
 	struct iovec iov[2];
-	struct msghdr msg = {0};
+	struct msghdr msg;
 	char cmsg[CLEN];
-	int len = 0, count;
-	size_t clen;
+	int len = 0, count, clen;
 	uint32_t tail;
 
 	if (!connection->want_flush)
@@ -304,10 +303,13 @@
 
 		build_cmsg(&connection->fds_out, cmsg, &clen);
 
+		msg.msg_name = NULL;
+		msg.msg_namelen = 0;
 		msg.msg_iov = iov;
 		msg.msg_iovlen = count;
 		msg.msg_control = (clen > 0) ? cmsg : NULL;
 		msg.msg_controllen = clen;
+		msg.msg_flags = 0;
 
 		do {
 			len = sendmsg(connection->fd, &msg,
@@ -566,10 +568,10 @@
 
 	if (size) {
 		*num_arrays = wl_message_count_arrays(message);
-		closure = zalloc(sizeof *closure + size +
+		closure = malloc(sizeof *closure + size +
 				 *num_arrays * sizeof(struct wl_array));
 	} else {
-		closure = zalloc(sizeof *closure);
+		closure = malloc(sizeof *closure);
 	}
 
 	if (!closure) {
@@ -808,12 +810,10 @@
 			}
 
 			if (wl_map_reserve_new(objects, id) < 0) {
-				if (errno == EINVAL) {
-					wl_log("not a valid new object id (%u), "
-					       "message %s(%s)\n", id,
-					       message->name,
-					       message->signature);
-				}
+				wl_log("not a valid new object id (%u), "
+				       "message %s(%s)\n",
+				       id, message->name, message->signature);
+				errno = EINVAL;
 				goto err;
 			}
 
@@ -1272,18 +1272,11 @@
 	struct timespec tp;
 	unsigned int time;
 	uint32_t nval;
-	FILE *f;
-	char *buffer;
-	size_t buffer_length;
-
-	f = open_memstream(&buffer, &buffer_length);
-	if (f == NULL)
-		return;
 
 	clock_gettime(CLOCK_REALTIME, &tp);
 	time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
 
-	fprintf(f, "[%7u.%03u] %s%s%s@%u.%s(",
+	fprintf(stderr, "[%7u.%03u] %s%s%s@%u.%s(",
 		time / 1000, time % 1000,
 		discarded ? "discarded " : "",
 		send ? " -> " : "",
@@ -1293,41 +1286,41 @@
 	for (i = 0; i < closure->count; i++) {
 		signature = get_next_argument(signature, &arg);
 		if (i > 0)
-			fprintf(f, ", ");
+			fprintf(stderr, ", ");
 
 		switch (arg.type) {
 		case 'u':
-			fprintf(f, "%u", closure->args[i].u);
+			fprintf(stderr, "%u", closure->args[i].u);
 			break;
 		case 'i':
-			fprintf(f, "%d", closure->args[i].i);
+			fprintf(stderr, "%d", closure->args[i].i);
 			break;
 		case 'f':
 			/* The magic number 390625 is 1e8 / 256 */
 			if (closure->args[i].f >= 0) {
-				fprintf(f, "%d.%08d",
+				fprintf(stderr, "%d.%08d",
 					closure->args[i].f / 256,
 					390625 * (closure->args[i].f % 256));
 			} else {
 
-				fprintf(f, "-%d.%08d",
+				fprintf(stderr, "-%d.%08d",
 					closure->args[i].f / -256,
 					-390625 * (closure->args[i].f % 256));
 			}
 			break;
 		case 's':
 			if (closure->args[i].s)
-				fprintf(f, "\"%s\"", closure->args[i].s);
+				fprintf(stderr, "\"%s\"", closure->args[i].s);
 			else
-				fprintf(f, "nil");
+				fprintf(stderr, "nil");
 			break;
 		case 'o':
 			if (closure->args[i].o)
-				fprintf(f, "%s@%u",
+				fprintf(stderr, "%s@%u",
 					closure->args[i].o->interface->name,
 					closure->args[i].o->id);
 			else
-				fprintf(f, "nil");
+				fprintf(stderr, "nil");
 			break;
 		case 'n':
 			if (n_parse)
@@ -1335,30 +1328,25 @@
 			else
 				nval = closure->args[i].n;
 
-			fprintf(f, "new id %s@",
+			fprintf(stderr, "new id %s@",
 				(closure->message->types[i]) ?
 				 closure->message->types[i]->name :
 				  "[unknown]");
 			if (nval != 0)
-				fprintf(f, "%u", nval);
+				fprintf(stderr, "%u", nval);
 			else
-				fprintf(f, "nil");
+				fprintf(stderr, "nil");
 			break;
 		case 'a':
-			fprintf(f, "array[%zu]", closure->args[i].a->size);
+			fprintf(stderr, "array[%zu]", closure->args[i].a->size);
 			break;
 		case 'h':
-			fprintf(f, "fd %d", closure->args[i].h);
+			fprintf(stderr, "fd %d", closure->args[i].h);
 			break;
 		}
 	}
 
-	fprintf(f, ")\n");
-
-	if (fclose(f) == 0) {
-		fprintf(stderr, "%s", buffer);
-		free(buffer);
-	}
+	fprintf(stderr, ")\n");
 }
 
 static int
--- wayland-1.21.0.orig/src/event-loop.c
+++ wayland-1.21.0/src/event-loop.c
@@ -179,7 +179,7 @@
 {
 	struct wl_event_source_fd *source;
 
-	source = zalloc(sizeof *source);
+	source = malloc(sizeof *source);
 	if (source == NULL)
 		return NULL;
 
@@ -568,7 +568,7 @@
 	if (wl_timer_heap_ensure_timerfd(&loop->timers) < 0)
 		return NULL;
 
-	source = zalloc(sizeof *source);
+	source = malloc(sizeof *source);
 	if (source == NULL)
 		return NULL;
 
@@ -718,7 +718,7 @@
 	struct wl_event_source_signal *source;
 	sigset_t mask;
 
-	source = zalloc(sizeof *source);
+	source = malloc(sizeof *source);
 	if (source == NULL)
 		return NULL;
 
@@ -775,7 +775,7 @@
 {
 	struct wl_event_source_idle *source;
 
-	source = zalloc(sizeof *source);
+	source = malloc(sizeof *source);
 	if (source == NULL)
 		return NULL;
 
@@ -885,7 +885,7 @@
 {
 	struct wl_event_loop *loop;
 
-	loop = zalloc(sizeof *loop);
+	loop = malloc(sizeof *loop);
 	if (loop == NULL)
 		return NULL;
 
--- wayland-1.21.0.orig/src/meson.build
+++ wayland-1.21.0/src/meson.build
@@ -1,7 +1,3 @@
-if not (get_option('scanner') or get_option('libraries'))
-	error('Either -Dscanner=true or -Dlibraries=true is required')
-endif
-
 wayland_version_h = configuration_data()
 wayland_version_h.set('WAYLAND_VERSION', meson.project_version())
 wayland_version_h.set('WAYLAND_VERSION_MAJOR', wayland_version[0].to_int())
@@ -71,15 +67,11 @@
 		],
 		filebase: 'wayland-scanner'
 	)
-
-	if meson.can_run_host_binaries()
-		meson.override_find_program('wayland-scanner', wayland_scanner)
-	endif
 endif
 
 if meson.is_cross_build() or not get_option('scanner')
 	scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())
-	wayland_scanner_for_build = find_program(scanner_dep.get_variable(pkgconfig: 'wayland_scanner'))
+	wayland_scanner_for_build = find_program(scanner_dep.get_pkgconfig_variable('wayland_scanner'))
 else
 	wayland_scanner_for_build = wayland_scanner
 endif
--- wayland-1.21.0.orig/src/wayland-client.c
+++ wayland-1.21.0/src/wayland-client.c
@@ -343,7 +343,7 @@
 {
 	struct wl_event_queue *queue;
 
-	queue = zalloc(sizeof *queue);
+	queue = malloc(sizeof *queue);
 	if (queue == NULL)
 		return NULL;
 
@@ -430,10 +430,6 @@
 	proxy->version = version;
 
 	proxy->object.id = wl_map_insert_new(&display->objects, 0, proxy);
-	if (proxy->object.id == 0) {
-		free(proxy);
-		return NULL;
-	}
 
 	return proxy;
 }
@@ -489,10 +485,7 @@
 	proxy->refcount = 1;
 	proxy->version = factory->version;
 
-	if (wl_map_insert_at(&display->objects, 0, id, proxy) == -1) {
-		free(proxy);
-		return NULL;
-	}
+	wl_map_insert_at(&display->objects, 0, id, proxy);
 
 	return proxy;
 }
@@ -1076,8 +1069,8 @@
 	path_is_absolute = name[0] == '/';
 
 	runtime_dir = getenv("XDG_RUNTIME_DIR");
-	if (((!runtime_dir || runtime_dir[0] != '/') && !path_is_absolute)) {
-		wl_log("error: XDG_RUNTIME_DIR is invalid or not set in the environment.\n");
+	if (!runtime_dir && !path_is_absolute) {
+		wl_log("error: XDG_RUNTIME_DIR not set in the environment.\n");
 		/* to prevent programs reporting
 		 * "failed to create display: Success" */
 		errno = ENOENT;
@@ -1162,16 +1155,11 @@
 	pthread_cond_init(&display->reader_cond, NULL);
 	display->reader_count = 0;
 
-	if (wl_map_insert_at(&display->objects, 0, 0, NULL) == -1)
-		goto err_connection;
+	wl_map_insert_new(&display->objects, 0, NULL);
 
+	display->proxy.object.interface = &wl_display_interface;
 	display->proxy.object.id =
 		wl_map_insert_new(&display->objects, 0, display);
-
-	if (display->proxy.object.id == 0)
-		goto err_connection;
-
-	display->proxy.object.interface = &wl_display_interface;
 	display->proxy.display = display;
 	display->proxy.object.implementation = (void(**)(void)) &display_listener;
 	display->proxy.user_data = display;
@@ -2311,19 +2299,6 @@
  * queued in \c queue from now. If queue is NULL, then the display's
  * default queue is set to the proxy.
  *
- * In order to guarantee proper handing of all events which were queued
- * before the queue change takes effect, it is required to dispatch the
- * proxy's old event queue after setting a new event queue.
- *
- * This is particularly important for multi-threaded setups, where it is
- * possible for events to be queued to the proxy's old queue from a
- * different thread during the invocation of this function.
- *
- * To ensure that all events for a newly created proxy are dispatched
- * on a particular queue, it is necessary to use a proxy wrapper if
- * events are read and dispatched on more than one thread. See
- * wl_proxy_create_wrapper() for more details.
- *
  * \note By default, the queue set in proxy is the one inherited from parent.
  *
  * \sa wl_display_dispatch_queue()
@@ -2333,16 +2308,12 @@
 WL_EXPORT void
 wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue)
 {
-	pthread_mutex_lock(&proxy->display->mutex);
-
 	if (queue) {
 		assert(proxy->display == queue->display);
 		proxy->queue = queue;
 	} else {
 		proxy->queue = &proxy->display->default_queue;
 	}
-
-	pthread_mutex_unlock(&proxy->display->mutex);
 }
 
 /** Create a proxy wrapper for making queue assignments thread-safe
--- wayland-1.21.0.orig/src/wayland-os.c
+++ wayland-1.21.0/src/wayland-os.c
@@ -231,22 +231,21 @@
 		     ssize_t new_size, int prot, int flags)
 {
 	void *result;
-
-	/* Make sure any pending write is flushed. */
-	if (msync(old_data, *old_size, MS_SYNC) != 0)
-		return MAP_FAILED;
-
-	/* We could try mapping a new block immediately after the current one
+	/*
+	 * We could try mapping a new block immediately after the current one
 	 * with MAP_FIXED, however that is not guaranteed to work and breaks
 	 * on CHERI-enabled architectures since the data pointer will still
-	 * have the bounds of the previous allocation.
+	 * have the bounds of the previous allocation. As this is not a
+	 * performance-critical path, we always map a new region and copy the
+	 * old data to the new region.
 	 */
 	result = mmap(NULL, new_size, prot, flags, fd, 0);
-	if (result == MAP_FAILED)
-		return MAP_FAILED;
-
-	if (munmap(old_data, *old_size) == 0)
-		*old_size = 0;
-
+	if (result != MAP_FAILED) {
+		/* Copy the data over and unmap the old mapping. */
+		memcpy(result, old_data, *old_size);
+		if (munmap(old_data, *old_size) == 0) {
+			*old_size = 0; /* successfully unmapped old data. */
+		}
+	}
 	return result;
 }
--- wayland-1.21.0.orig/src/wayland-private.h
+++ wayland-1.21.0/src/wayland-private.h
@@ -45,7 +45,6 @@
 #define WL_MAP_SERVER_SIDE 0
 #define WL_MAP_CLIENT_SIDE 1
 #define WL_SERVER_ID_START 0xff000000
-#define WL_MAP_MAX_OBJECTS 0x00f00000
 #define WL_CLOSURE_MAX_ARGS 20
 
 struct wl_object {
--- wayland-1.21.0.orig/src/wayland-server-core.h
+++ wayland-1.21.0/src/wayland-server-core.h
@@ -279,9 +279,6 @@
 const struct wl_interface *
 wl_global_get_interface(const struct wl_global *global);
 
-uint32_t
-wl_global_get_version(const struct wl_global *global);
-
 struct wl_display *
 wl_global_get_display(const struct wl_global *global);
 
@@ -484,9 +481,6 @@
 		l->notify(l, data);
 }
 
-void
-wl_signal_emit_mutable(struct wl_signal *signal, void *data);
-
 typedef void (*wl_resource_destroy_func_t)(struct wl_resource *resource);
 
 /*
--- wayland-1.21.0.orig/src/wayland-server.c
+++ wayland-1.21.0/src/wayland-server.c
@@ -578,9 +578,6 @@
  * SO_PEERCRED, on the client socket fd.  All the pointers can be
  * NULL, if the caller is not interested in a particular ID.
  *
- * Note, process IDs are subject to race conditions and are not a reliable way
- * to identify a client.
- *
  * Be aware that for clients that a compositor forks and execs and
  * then connects using socketpair(), this function will return the
  * credentials for the compositor.  The credentials for the socketpair
@@ -1065,7 +1062,7 @@
 	if (debug && (strstr(debug, "server") || strstr(debug, "1")))
 		debug_server = 1;
 
-	display = zalloc(sizeof *display);
+	display = malloc(sizeof *display);
 	if (display == NULL)
 		return NULL;
 
@@ -1208,10 +1205,6 @@
  * Setting the filter NULL will result in all globals being
  * advertised to all clients. The default is no filter.
  *
- * The filter should be installed before any client connects and should always
- * take the same decision given a client and a global. Not doing so will result
- * in inconsistent filtering and broken wl_registry event sequences.
- *
  * \memberof wl_display
  */
 WL_EXPORT void
@@ -1245,7 +1238,7 @@
 		return NULL;
 	}
 
-	global = zalloc(sizeof *global);
+	global = malloc(sizeof *global);
 	if (global == NULL)
 		return NULL;
 
@@ -1259,12 +1252,11 @@
 	wl_list_insert(display->global_list.prev, &global->link);
 
 	wl_list_for_each(resource, &display->registry_resource_list, link)
-		if (wl_global_is_visible(resource->client, global))
-			wl_resource_post_event(resource,
-					       WL_REGISTRY_GLOBAL,
-					       global->name,
-					       global->interface->name,
-					       global->version);
+		wl_resource_post_event(resource,
+				       WL_REGISTRY_GLOBAL,
+				       global->name,
+				       global->interface->name,
+				       global->version);
 
 	return global;
 }
@@ -1302,9 +1294,8 @@
 			 global->name);
 
 	wl_list_for_each(resource, &display->registry_resource_list, link)
-		if (wl_global_is_visible(resource->client, global))
-			wl_resource_post_event(resource, WL_REGISTRY_GLOBAL_REMOVE,
-					       global->name);
+		wl_resource_post_event(resource, WL_REGISTRY_GLOBAL_REMOVE,
+				       global->name);
 
 	global->removed = true;
 }
@@ -1324,20 +1315,6 @@
 	return global->interface;
 }
 
-/** Get the version of the given global.
- *
- * \param global The global object.
- * \return The version advertised by the global.
- *
- * \memberof wl_global
- * \since 1.21
- */
-WL_EXPORT uint32_t
-wl_global_get_version(const struct wl_global *global)
-{
-	return global->version;
-}
-
 /** Get the display object for the given global
  *
  * \param global The global object
@@ -1566,9 +1543,8 @@
 
 	if (name[0] != '/') {
 		runtime_dir = getenv("XDG_RUNTIME_DIR");
-		if (!runtime_dir || runtime_dir[0] != '/') {
-			wl_log("error: XDG_RUNTIME_DIR is invalid or not set in"
-			       " the environment\n");
+		if (!runtime_dir) {
+			wl_log("error: XDG_RUNTIME_DIR not set in the environment\n");
 
 			/* to prevent programs reporting
 			 * "failed to add socket: Success" */
@@ -1728,7 +1704,7 @@
  *
  * If the socket name is a relative path, the Unix socket will be created in
  * the directory pointed to by environment variable XDG_RUNTIME_DIR. If
- * XDG_RUNTIME_DIR is invalid or not set, then this function fails and returns -1.
+ * XDG_RUNTIME_DIR is not set, then this function fails and returns -1.
  *
  * If the socket name is an absolute path, then it is used as-is for the
  * the Unix socket.
@@ -1846,17 +1822,12 @@
 {
 	struct wl_resource *resource;
 
-	resource = zalloc(sizeof *resource);
+	resource = malloc(sizeof *resource);
 	if (resource == NULL)
 		return NULL;
 
-	if (id == 0) {
+	if (id == 0)
 		id = wl_map_insert_new(&client->objects, 0, NULL);
-		if (id == 0) {
-			free(resource);
-			return NULL;
-		}
-	}
 
 	resource->object.id = id;
 	resource->object.interface = interface;
@@ -1872,11 +1843,9 @@
 	resource->dispatcher = NULL;
 
 	if (wl_map_insert_at(&client->objects, 0, id, resource) < 0) {
-		if (errno == EINVAL) {
-			wl_resource_post_error(client->display_resource,
-					       WL_DISPLAY_ERROR_INVALID_OBJECT,
-					       "invalid new id %d", id);
-		}
+		wl_resource_post_error(client->display_resource,
+				       WL_DISPLAY_ERROR_INVALID_OBJECT,
+				       "invalid new id %d", id);
 		free(resource);
 		return NULL;
 	}
@@ -1919,7 +1888,7 @@
 {
 	struct wl_protocol_logger *logger;
 
-	logger = zalloc(sizeof *logger);
+	logger = malloc(sizeof *logger);
 	if (!logger)
 		return NULL;
 
@@ -2120,69 +2089,6 @@
 	wl_map_for_each(&client->objects, resource_iterator_helper, &context);
 }
 
-static void
-handle_noop(struct wl_listener *listener, void *data)
-{
-	/* Do nothing */
-}
-
-/** Emits this signal, notifying all registered listeners.
- *
- * A safer version of wl_signal_emit() which can gracefully handle additions
- * and deletions of any signal listener from within listener notification
- * callbacks.
- *
- * Listeners deleted during a signal emission and which have not already been
- * notified at the time of deletion are not notified by that emission.
- *
- * Listeners added (or readded) during signal emission are ignored by that
- * emission.
- *
- * Note that repurposing a listener without explicitly removing it and readding
- * it is not supported and can lead to unexpected behavior.
- *
- * \param signal The signal object that will emit the signal
- * \param data The data that will be emitted with the signal
- *
- * \memberof wl_signal
- * \since 1.20.90
- */
-WL_EXPORT void
-wl_signal_emit_mutable(struct wl_signal *signal, void *data)
-{
-	struct wl_listener cursor;
-	struct wl_listener end;
-
-	/* Add two special markers: one cursor and one end marker. This way, we
-	 * know that we've already called listeners on the left of the cursor
-	 * and that we don't want to call listeners on the right of the end
-	 * marker. The 'it' function can remove any element it wants from the
-	 * list without troubles.
-	 *
-	 * There was a previous attempt that used to steal the whole list of
-	 * listeners but then that broke wl_signal_get().
-	 *
-	 * wl_list_for_each_safe tries to be safe but it fails: it works fine
-	 * if the current item is removed, but not if the next one is. */
-	wl_list_insert(&signal->listener_list, &cursor.link);
-	cursor.notify = handle_noop;
-	wl_list_insert(signal->listener_list.prev, &end.link);
-	end.notify = handle_noop;
-
-	while (cursor.link.next != &end.link) {
-		struct wl_list *pos = cursor.link.next;
-		struct wl_listener *l = wl_container_of(pos, l, link);
-
-		wl_list_remove(&cursor.link);
-		wl_list_insert(pos, &cursor.link);
-
-		l->notify(l, data);
-	}
-
-	wl_list_remove(&cursor.link);
-	wl_list_remove(&end.link);
-}
-
 /** \cond INTERNAL */
 
 /** Initialize a wl_priv_signal object
@@ -2332,16 +2238,12 @@
 		resource->object.id =
 			wl_map_insert_new(&client->objects,
 					  WL_MAP_ENTRY_LEGACY, resource);
-		if (resource->object.id == 0)
-			return 0;
 	} else if (wl_map_insert_at(&client->objects, WL_MAP_ENTRY_LEGACY,
 				  resource->object.id, resource) < 0) {
-		if (errno == EINVAL) {
-			wl_resource_post_error(client->display_resource,
-					       WL_DISPLAY_ERROR_INVALID_OBJECT,
-					       "invalid new id %d",
-					       resource->object.id);
-		}
+		wl_resource_post_error(client->display_resource,
+				       WL_DISPLAY_ERROR_INVALID_OBJECT,
+				       "invalid new id %d",
+				       resource->object.id);
 		return 0;
 	}
 
--- wayland-1.21.0.orig/src/wayland-shm.c
+++ wayland-1.21.0/src/wayland-shm.c
@@ -65,12 +65,10 @@
 	char *data;
 	ssize_t size;
 	ssize_t new_size;
-#ifndef MREMAP_MAYMOVE
 	/* The following three fields are needed for mremap() emulation. */
 	int mmap_fd;
 	int mmap_flags;
 	int mmap_prot;
-#endif
 	bool sigbus_is_impossible;
 };
 
@@ -155,9 +153,7 @@
 		return;
 
 	munmap(pool->data, pool->size);
-#ifndef MREMAP_MAYMOVE
 	close(pool->mmap_fd);
-#endif
 	free(pool);
 }
 
@@ -227,7 +223,7 @@
 		return;
 	}
 
-	buffer = zalloc(sizeof *buffer);
+	buffer = malloc(sizeof *buffer);
 	if (buffer == NULL) {
 		wl_client_post_no_memory(client);
 		return;
@@ -316,7 +312,7 @@
 		goto err_close;
 	}
 
-	pool = zalloc(sizeof *pool);
+	pool = malloc(sizeof *pool);
 	if (pool == NULL) {
 		wl_client_post_no_memory(client);
 		goto err_close;
@@ -348,14 +344,10 @@
 				       strerror(errno));
 		goto err_free;
 	}
-#ifndef MREMAP_MAYMOVE
 	/* We may need to keep the fd, prot and flags to emulate mremap(). */
 	pool->mmap_fd = fd;
 	pool->mmap_prot = prot;
 	pool->mmap_flags = flags;
-#else
-	close(fd);
-#endif
 	pool->resource =
 		wl_resource_create(client, &wl_shm_pool_interface, 1, id);
 	if (!pool->resource) {
--- wayland-1.21.0.orig/src/wayland-util.c
+++ wayland-1.21.0/src/wayland-util.c
@@ -24,7 +24,6 @@
  * SOFTWARE.
  */
 
-#include <errno.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -198,7 +197,6 @@
 	union map_entry *start, *entry;
 	struct wl_array *entries;
 	uint32_t base;
-	uint32_t count;
 
 	if (map->side == WL_MAP_CLIENT_SIDE) {
 		entries = &map->client_entries;
@@ -219,26 +217,10 @@
 		start = entries->data;
 	}
 
-	/* wl_array only grows, so if we have too many objects at
-	 * this point there's no way to clean up. We could be more
-	 * pro-active about trying to avoid this allocation, but
-	 * it doesn't really matter because at this point there is
-	 * nothing to be done but disconnect the client and delete
-	 * the whole array either way.
-	 */
-	count = entry - start;
-	if (count > WL_MAP_MAX_OBJECTS) {
-		/* entry->data is freshly malloced garbage, so we'd
-		 * better make it a NULL so wl_map_for_each doesn't
-		 * dereference it later. */
-		entry->data = NULL;
-		errno = ENOSPC;
-		return 0;
-	}
 	entry->data = data;
 	entry->next |= (flags & 0x1) << 1;
 
-	return count + base;
+	return (entry - start) + base;
 }
 
 int
@@ -255,21 +237,12 @@
 		i -= WL_SERVER_ID_START;
 	}
 
-	if (i > WL_MAP_MAX_OBJECTS) {
-		errno = ENOSPC;
-		return -1;
-	}
-
 	count = entries->size / sizeof *start;
-	if (count < i) {
-		errno = EINVAL;
+	if (count < i)
 		return -1;
-	}
 
-	if (count == i) {
-		if (!wl_array_add(entries, sizeof *start))
-			return -1;
-	}
+	if (count == i)
+		wl_array_add(entries, sizeof *start);
 
 	start = entries->data;
 	start[i].data = data;
@@ -286,43 +259,30 @@
 	struct wl_array *entries;
 
 	if (i < WL_SERVER_ID_START) {
-		if (map->side == WL_MAP_CLIENT_SIDE) {
-			errno = EINVAL;
+		if (map->side == WL_MAP_CLIENT_SIDE)
 			return -1;
-		}
 
 		entries = &map->client_entries;
 	} else {
-		if (map->side == WL_MAP_SERVER_SIDE) {
-			errno = EINVAL;
+		if (map->side == WL_MAP_SERVER_SIDE)
 			return -1;
-		}
 
 		entries = &map->server_entries;
 		i -= WL_SERVER_ID_START;
 	}
 
-	if (i > WL_MAP_MAX_OBJECTS) {
-		errno = ENOSPC;
-		return -1;
-	}
-
 	count = entries->size / sizeof *start;
-	if (count < i) {
-		errno = EINVAL;
+
+	if (count < i)
 		return -1;
-	}
 
 	if (count == i) {
-		if (!wl_array_add(entries, sizeof *start))
-			return -1;
-
+		wl_array_add(entries, sizeof *start);
 		start = entries->data;
 		start[i].data = NULL;
 	} else {
 		start = entries->data;
 		if (start[i].data != NULL) {
-			errno = EINVAL;
 			return -1;
 		}
 	}
--- wayland-1.21.0.orig/src/wayland-util.h
+++ wayland-1.21.0/src/wayland-util.h
@@ -182,7 +182,7 @@
  * For example, consider a protocol interface `foo`, marked as version `1`, with
  * two requests and one event.
  *
- * \code{.xml}
+ * \code
  * <interface name="foo" version="1">
  *   <request name="a"></request>
  *   <request name="b"></request>
--- wayland-1.21.0.orig/tests/compositor-introspection-test.c
+++ wayland-1.21.0/tests/compositor-introspection-test.c
@@ -40,7 +40,7 @@
 require_xdg_runtime_dir(void)
 {
 	char *val = getenv("XDG_RUNTIME_DIR");
-	assert(val && val[0] == '/' && "set $XDG_RUNTIME_DIR to run this test");
+	assert(val && "set $XDG_RUNTIME_DIR to run this test");
 
 	return val;
 }
--- wayland-1.21.0.orig/tests/data/example-client.h
+++ wayland-1.21.0/tests/data/example-client.h
@@ -2400,7 +2400,7 @@
 	 * which will subsequently be used in either the data_device.enter
 	 * event (for drag-and-drop) or the data_device.selection event
 	 * (for selections). Immediately following the
-	 * data_device.data_offer event, the new data_offer object will
+	 * data_device_data_offer event, the new data_offer object will
 	 * send out data_offer.offer events to describe the mime types it
 	 * offers.
 	 * @param id the new data_offer object
--- wayland-1.21.0.orig/tests/data/example.xml
+++ wayland-1.21.0/tests/data/example.xml
@@ -812,7 +812,7 @@
 	which will subsequently be used in either the
 	data_device.enter event (for drag-and-drop) or the
 	data_device.selection event (for selections).  Immediately
-	following the data_device.data_offer event, the new data_offer
+	following the data_device_data_offer event, the new data_offer
 	object will send out data_offer.offer events to describe the
 	mime types it offers.
       </description>
--- wayland-1.21.0.orig/tests/display-test.c
+++ wayland-1.21.0/tests/display-test.c
@@ -24,7 +24,6 @@
  * SOFTWARE.
  */
 
-#define _GNU_SOURCE
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -1006,16 +1005,9 @@
 	}
 }
 
-static void
-registry_handle_remove_filtered(void *data, struct wl_registry *registry,
-				uint32_t id)
-{
-	assert(false);
-}
-
 static const struct wl_registry_listener registry_listener_filtered = {
 	registry_handle_filtered,
-	registry_handle_remove_filtered,
+	NULL
 };
 
 static void
@@ -1050,58 +1042,6 @@
 
 	display_destroy(d);
 }
-
-static void
-get_dynamic_globals(void *data)
-{
-	struct client *c = client_connect();
-	struct wl_registry *registry;
-
-	registry = wl_display_get_registry(c->wl_display);
-	wl_registry_add_listener(registry, &registry_listener_filtered, data);
-	wl_display_roundtrip(c->wl_display);
-
-	/* Wait for the server to create a new global */
-	assert(stop_display(c, 1) >= 0);
-
-	/* Check that we don't see it */
-	wl_display_roundtrip(c->wl_display);
-
-	/* Wait for the server to remove that global */
-	assert(stop_display(c, 1) >= 0);
-
-	/* Check that we don't get a global_remove event */
-	wl_display_roundtrip(c->wl_display);
-
-	wl_registry_destroy(registry);
-	client_disconnect_nocheck(c);
-}
-
-TEST(filtered_dynamic_global_is_hidden)
-{
-	struct display *d;
-	struct wl_global *g;
-
-	d = display_create();
-	wl_display_set_global_filter(d->wl_display, global_filter, NULL);
-
-	/* Create a client and let it enumerate the globals */
-	client_create_noarg(d, get_dynamic_globals);
-	display_run(d);
-
-	/* Dynamically create a new global */
-	g = wl_global_create(d->wl_display, &wl_data_offer_interface,
-			     1, d, bind_data_offer);
-
-	display_resume(d);
-
-	/* Dynamically remove the global */
-	wl_global_destroy(g);
-
-	display_resume(d);
-
-	display_destroy(d);
-}
 
 static void
 check_bind_error(struct client *c)
--- wayland-1.21.0.orig/tests/event-loop-test.c
+++ wayland-1.21.0/tests/event-loop-test.c
@@ -24,7 +24,6 @@
  * SOFTWARE.
  */
 
-#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdint.h>
 #include <assert.h>
--- wayland-1.21.0.orig/tests/fixed-test.c
+++ wayland-1.21.0/tests/fixed-test.c
@@ -23,7 +23,6 @@
  * SOFTWARE.
  */
 
-#define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
--- wayland-1.21.0.orig/tests/meson.build
+++ wayland-1.21.0/tests/meson.build
@@ -1,7 +1,3 @@
-if not get_option('libraries')
-	error('-Dtests=true requires -Dlibraries=true')
-endif
-
 test_runner = static_library(
 	'test-runner',
 	sources: [
@@ -69,7 +65,7 @@
 	dependencies: test_runner_dep
 )
 
-if add_languages('cpp', native: false)
+if add_languages('cpp')
 	test(
 		'cpp-compile-test',
 		executable(
@@ -81,7 +77,7 @@
 	)
 endif
 
-sed_path = find_program('sed').full_path()
+sed_path = find_program('sed').path()
 
 if get_option('scanner')
 	test(
--- wayland-1.21.0.orig/tests/os-wrappers-test.c
+++ wayland-1.21.0/tests/os-wrappers-test.c
@@ -70,7 +70,7 @@
 
 #define REAL(func) (__interceptor_ ## func) ?				\
 	__interceptor_ ## func :					\
-	(__typeof__(&__interceptor_ ## func))dlsym(RTLD_NEXT, #func)
+	(typeof(&__interceptor_ ## func))dlsym(RTLD_NEXT, #func)
 
 DECL(int, socket, int, int, int);
 DECL(int, fcntl, int, int, ...);
--- wayland-1.21.0.orig/tests/protocol-logger-test.c
+++ wayland-1.21.0/tests/protocol-logger-test.c
@@ -40,7 +40,7 @@
 require_xdg_runtime_dir(void)
 {
 	char *val = getenv("XDG_RUNTIME_DIR");
-	assert(val && val[0] == '/' && "set $XDG_RUNTIME_DIR to run this test");
+	assert(val && "set $XDG_RUNTIME_DIR to run this test");
 
 	return val;
 }
--- wayland-1.21.0.orig/tests/sanity-test.c
+++ wayland-1.21.0/tests/sanity-test.c
@@ -174,7 +174,7 @@
 {
 	struct display *d = display_create();
 
-	client_create_noarg(d, sanity_fd_leak_exec);
+	client_create_noarg(d, sanity_fd_leak);
 	display_run(d);
 
 	test_disable_coredumps();
--- wayland-1.21.0.orig/tests/signal-test.c
+++ wayland-1.21.0/tests/signal-test.c
@@ -115,44 +115,3 @@
 
 	assert(3 * counter == count);
 }
-
-struct signal_emit_mutable_data {
-	int count;
-	struct wl_listener *remove_listener;
-};
-
-static void
-signal_notify_mutable(struct wl_listener *listener, void *data)
-{
-	struct signal_emit_mutable_data *test_data = data;
-	test_data->count++;
-}
-
-static void
-signal_notify_and_remove_mutable(struct wl_listener *listener, void *data)
-{
-	struct signal_emit_mutable_data *test_data = data;
-	signal_notify_mutable(listener, test_data);
-	wl_list_remove(&test_data->remove_listener->link);
-}
-
-TEST(signal_emit_mutable)
-{
-	struct signal_emit_mutable_data data = {0};
-
-	/* l2 will remove l3 before l3 is notified */
-	struct wl_signal signal;
-	struct wl_listener l1 = {.notify = signal_notify_mutable};
-	struct wl_listener l2 = {.notify = signal_notify_and_remove_mutable};
-	struct wl_listener l3 = {.notify = signal_notify_mutable};
-
-	wl_signal_init(&signal);
-	wl_signal_add(&signal, &l1);
-	wl_signal_add(&signal, &l2);
-	wl_signal_add(&signal, &l3);
-
-	data.remove_listener = &l3;
-	wl_signal_emit_mutable(&signal, &data);
-
-	assert(data.count == 2);
-}
--- wayland-1.21.0.orig/tests/socket-test.c
+++ wayland-1.21.0/tests/socket-test.c
@@ -51,7 +51,7 @@
 require_xdg_runtime_dir(void)
 {
 	char *val = getenv("XDG_RUNTIME_DIR");
-	assert(val && val[0] == '/' && "set $XDG_RUNTIME_DIR to run this test");
+	assert(val && "set $XDG_RUNTIME_DIR to run this test");
 
 	return val;
 }
--- wayland-1.21.0.orig/tests/test-compositor.h
+++ wayland-1.21.0/tests/test-compositor.h
@@ -25,7 +25,6 @@
 
 #include <stdint.h>
 #include <unistd.h>
-#include <stdatomic.h>
 
 #include "wayland-server.h"
 #include "wayland-client.h"
@@ -66,7 +65,7 @@
 	struct wl_display *wl_display;
 	struct test_compositor *tc;
 
-	atomic_bool display_stopped;
+	int display_stopped;
 };
 
 struct client *client_connect(void);
--- wayland-1.21.0.orig/tests/test-runner.c
+++ wayland-1.21.0/tests/test-runner.c
@@ -180,7 +180,7 @@
 	xrd_env = getenv("XDG_RUNTIME_DIR");
 	/* if XDG_RUNTIME_DIR is not set in environ, fallback to /tmp */
 	assert((snprintf(xdg_runtime_dir, PATH_MAX, "%s/wayland-tests-XXXXXX",
-			 (xrd_env && xrd_env[0] == '/') ? xrd_env : "/tmp") < PATH_MAX)
+			 xrd_env ? xrd_env : "/tmp") < PATH_MAX)
 		&& "test error: XDG_RUNTIME_DIR too long");
 
 	assert(mkdtemp(xdg_runtime_dir) && "test error: mkdtemp failed");
@@ -200,7 +200,7 @@
 rmdir_xdg_runtime_dir(void)
 {
 	const char *xrd_env = getenv("XDG_RUNTIME_DIR");
-	assert(xrd_env && xrd_env[0] == '/' && "No XDG_RUNTIME_DIR set");
+	assert(xrd_env && "No XDG_RUNTIME_DIR set");
 
 	/* rmdir may fail if some test didn't do clean up */
 	if (rmdir(xrd_env) == -1)
