Projects
openEuler:Mainline
wayland
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
_service:tar_scm:wayland.spec
Changed
@@ -1,15 +1,16 @@ Name: wayland -Version: 1.20.0 -Release: 4 +Version: 1.21.0 +Release: 2 Summary: Wayland Compositor Infrastructure License: MIT -URL: http://wayland.freedesktop.org/ -Source0: http://wayland.freedesktop.org/releases/%{name}-%{version}.tar.xz +URL: https://wayland.freedesktop.org/ +Source0: https://gitlab.freedesktop.org/wayland/wayland/-/archive/%{version}/%{name}-%{version}.tar.gz BuildRequires: gcc gcc-c++ docbook-style-xsl doxygen expat-devel BuildRequires: libxml2-devel libxslt pkgconfig(libffi) xmlto graphviz meson chrpath Provides: libwayland-client = %{version}-%{release} libwayland-cursor = %{version}-%{release} +Provides: libwayland-client%{?_isa} = %{version}-%{release} libwayland-cursor%{?_isa} = %{version}-%{release} Obsoletes: libwayland-client < %{version}-%{release} libwayland-cursor < %{version}-%{release} Provides: libwayland-egl = %{version}-%{release} libwayland-server = %{version}-%{release} Obsoletes: libwayland-egl < %{version}-%{release} libwayland-server < %{version}-%{release} @@ -92,6 +93,15 @@ %{_datadir}/doc/wayland/ %changelog +* Fri Dec 30 2022 lin zhang <lin.zhang@turbolinux.com.cn> - 1.21.0-2 +- add Provides:libwayland-client%{?_isa} and libwayland-cursor%{?_isa} + +* Wed Dec 14 2022 lijian <lijian2@kylinos.cn> - 1.21.0-1 +- update to 1.21.0 + +* Sat Aug 27 2022 tianlijing <tianlijing@kylinos.cn> - 1.20.92-1 +- update to 1.20.92 + * Thu Jun 16 2022 wangkerong <wangkerong@h-partners.com> - 1.20.0-4 - CVE:NA - SUG:NA
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="scm">git</param> <param name="url">git@gitee.com:src-openeuler/wayland.git</param> - <param name="revision">4a51662d7cc84362db574c353f6b7a333b8e25e9</param> + <param name="revision">master</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
View file
_service:tar_scm:wayland-1.20.0.tar.xz/publish-doc
Deleted
@@ -1,15 +0,0 @@ -#!/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/
View file
_service:tar_scm:wayland-1.20.0.tar.xz/.gitlab-ci.yml -> _service:tar_scm:wayland-1.21.0.tar.gz/.gitlab-ci.yml
Changed
@@ -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.52.1' + FDO_DISTRIBUTION_EXEC: 'pip3 install meson==0.56.0' # bump this tag every time you change something which requires rebuilding the # base image - FDO_DISTRIBUTION_TAG: "2021-08-03.0" + FDO_DISTRIBUTION_TAG: "2022-02-05.0" .debian-x86_64: extends:
View file
_service:tar_scm:wayland-1.20.0.tar.xz/cursor/os-compatibility.c -> _service:tar_scm:wayland-1.21.0.tar.gz/cursor/os-compatibility.c
Changed
@@ -31,7 +31,9 @@ #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 @@ -118,6 +120,7 @@ static const char template = "/wayland-cursor-shared-XXXXXX"; const char *path; char *name; + size_t name_size; int fd; #ifdef HAVE_MEMFD_CREATE @@ -134,17 +137,17 @@ #endif { path = getenv("XDG_RUNTIME_DIR"); - if (!path) { + if (!path || path0 != '/') { errno = ENOENT; return -1; } - name = malloc(strlen(path) + sizeof(template)); + name_size = strlen(path) + sizeof(template); + name = malloc(name_size); if (!name) return -1; - strcpy(name, path); - strcat(name, template); + snprintf(name, name_size, "%s%s", path, template); fd = create_tmpfile_cloexec(name); @@ -166,11 +169,28 @@ os_resize_anonymous_file(int fd, off_t size) { #ifdef HAVE_POSIX_FALLOCATE - /* - * Filesystems that do support fallocate will return EINVAL or + 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 * EOPNOTSUPP. In this case we need to fall back to ftruncate */ - errno = posix_fallocate(fd, 0, size); + do { + errno = posix_fallocate(fd, 0, size); + } while (errno == EINTR); + sigprocmask(SIG_SETMASK, &old_mask, NULL); if (errno == 0) return 0; else if (errno != EINVAL && errno != EOPNOTSUPP)
View file
_service:tar_scm:wayland-1.20.0.tar.xz/cursor/wayland-cursor.c -> _service:tar_scm:wayland-1.21.0.tar.gz/cursor/wayland-cursor.c
Changed
@@ -92,7 +92,7 @@ pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, pool->fd, 0); - if (pool->data == (void *)-1) + if (pool->data == MAP_FAILED) return 0; pool->size = size; @@ -274,7 +274,7 @@ } static struct wl_cursor * -wl_cursor_create_from_xcursor_images(XcursorImages *images, +wl_cursor_create_from_xcursor_images(struct xcursor_images *images, struct wl_cursor_theme *theme) { struct cursor *cursor; @@ -335,13 +335,13 @@ } static void -load_callback(XcursorImages *images, void *data) +load_callback(struct xcursor_images *images, void *data) { struct wl_cursor_theme *theme = data; struct wl_cursor *cursor; if (wl_cursor_theme_get_cursor(theme, images->name)) { - XcursorImagesDestroy(images); + xcursor_images_destroy(images); return; } @@ -361,7 +361,7 @@ } } - XcursorImagesDestroy(images); + xcursor_images_destroy(images); } /** Load a cursor theme to memory shared with the compositor
View file
_service:tar_scm:wayland-1.20.0.tar.xz/cursor/xcursor.c -> _service:tar_scm:wayland-1.21.0.tar.gz/cursor/xcursor.c
Changed
@@ -23,20 +23,15 @@ * 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 @@ -67,43 +62,31 @@ * CARD32 position absolute file position */ -#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)) +#define XCURSOR_MAGIC 0x72756358 /* "Xcur" LSBFirst */ /* * 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) - -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; +#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 */ +}; /* * The rest of the file is a list of chunks, each tagged by type @@ -121,42 +104,14 @@ * CARD32 version chunk type version */ -#define XCURSOR_CHUNK_HEADER_LEN (4 * 4) - -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 +#define XCURSOR_CHUNK_HEADER_LEN (4 * 4) -typedef struct _XcursorComment { - XcursorUInt version; - XcursorUInt comment_type; - char *comment; -} XcursorComment; +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 */ +}; /* * Each cursor image occupies a separate image chunk. @@ -174,439 +129,354 @@ * 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 */ - -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; +#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 */ /* * From libXcursor/src/file.c */ -static XcursorImage * -XcursorImageCreate (int width, int height) +static struct xcursor_image * +xcursor_image_create(int width, int height) { - 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 (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; + struct xcursor_image *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; } static void -XcursorImageDestroy (XcursorImage *image) +xcursor_image_destroy(struct xcursor_image *image) { - free (image); + free(image); } -static XcursorImages * -XcursorImagesCreate (int size) +static struct xcursor_images * +xcursor_images_create(int size) { - XcursorImages *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; + struct xcursor_images *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; } void -XcursorImagesDestroy (XcursorImages *images) +xcursor_images_destroy(struct xcursor_images *images) { - int n; - - if (!images) - return; + int n; - for (n = 0; n < images->nimage; n++) - XcursorImageDestroy (images->imagesn); - if (images->name) - free (images->name); - free (images); -} - -static void -XcursorImagesSetName (XcursorImages *images, const char *name) -{ - char *new; - - if (!images || !name) - return; - - new = malloc (strlen (name) + 1); - - if (!new) - return; + if (!images) + return; - strcpy (new, name); - if (images->name) - free (images->name); - images->name = new; + for (n = 0; n < images->nimage; n++) + xcursor_image_destroy(images->imagesn); + free(images->name); + free(images); } -static XcursorBool -_XcursorReadUInt (XcursorFile *file, XcursorUInt *u) +static bool +xcursor_read_uint(FILE *file, uint32_t *u) { - unsigned char bytes4; + unsigned char bytes4; - if (!file || !u) - return XcursorFalse; + if (!file || !u) + return false; - if ((*file->read) (file, bytes, 4) != 4) - return XcursorFalse; + if (fread(bytes, 1, 4, file) != 4) + return false; - *u = ((XcursorUInt)(bytes0) << 0) | - ((XcursorUInt)(bytes1) << 8) | - ((XcursorUInt)(bytes2) << 16) | - ((XcursorUInt)(bytes3) << 24); - return XcursorTrue; + *u = ((uint32_t)(bytes0) << 0) | + ((uint32_t)(bytes1) << 8) | + ((uint32_t)(bytes2) << 16) | + ((uint32_t)(bytes3) << 24); + return true; } static void -_XcursorFileHeaderDestroy (XcursorFileHeader *fileHeader) +xcursor_file_header_destroy(struct xcursor_file_header *file_header) { - free (fileHeader); + free(file_header); } -static XcursorFileHeader * -_XcursorFileHeaderCreate (XcursorUInt ntoc) +static struct xcursor_file_header * +xcursor_file_header_create(uint32_t 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; + 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 XcursorFileHeader * -_XcursorReadFileHeader (XcursorFile *file) +static struct xcursor_file_header * +xcursor_read_file_header(FILE *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->tocsn.type)) - break; - if (!_XcursorReadUInt (file, &fileHeader->tocsn.subtype)) - break; - if (!_XcursorReadUInt (file, &fileHeader->tocsn.position)) - break; - } - if (n != fileHeader->ntoc) - { - _XcursorFileHeaderDestroy (fileHeader); - return NULL; - } - return fileHeader; + 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->tocsn.type)) + break; + if (!xcursor_read_uint(file, &file_header->tocsn.subtype)) + break; + if (!xcursor_read_uint(file, &file_header->tocsn.position)) + break; + } + if (n != file_header->ntoc) { + xcursor_file_header_destroy(file_header); + return NULL; + } + return file_header; } -static XcursorBool -_XcursorSeekToToc (XcursorFile *file, - XcursorFileHeader *fileHeader, - int toc) +static bool +xcursor_seek_to_toc(FILE *file, + struct xcursor_file_header *file_header, + int toc) { - if (!file || !fileHeader || \ - (*file->seek) (file, fileHeader->tocstoc.position, SEEK_SET) == EOF) - return XcursorFalse; - return XcursorTrue; + if (!file || !file_header || + fseek(file, file_header->tocstoc.position, SEEK_SET) == EOF) + return false; + return true; } -static XcursorBool -_XcursorFileReadChunkHeader (XcursorFile *file, - XcursorFileHeader *fileHeader, - int toc, - XcursorChunkHeader *chunkHeader) +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 || !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->tocstoc.type || - chunkHeader->subtype != fileHeader->tocstoc.subtype) - return XcursorFalse; - return XcursorTrue; + 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->tocstoc.type || + chunk_header->subtype != file_header->tocstoc.subtype) + return false; + return true; } -#define dist(a,b) ((a) > (b) ? (a) - (b) : (b) - (a)) - -static XcursorDim -_XcursorFindBestSize (XcursorFileHeader *fileHeader, - XcursorDim size, - int *nsizesp) +static uint32_t +dist(uint32_t a, uint32_t b) { - 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->tocsn.type != XCURSOR_IMAGE_TYPE) - continue; - thisSize = fileHeader->tocsn.subtype; - if (!bestSize || dist (thisSize, size) < dist (bestSize, size)) - { - bestSize = thisSize; - nsizes = 1; - } - else if (thisSize == bestSize) - nsizes++; - } - *nsizesp = nsizes; - return bestSize; + return a > b ? a - b : b - a; } -static int -_XcursorFindImageToc (XcursorFileHeader *fileHeader, - XcursorDim size, - int count) +static uint32_t +xcursor_file_best_size(struct xcursor_file_header *file_header, + uint32_t size, int *nsizesp) { - unsigned int toc; - XcursorDim thisSize; - - if (!fileHeader) - return 0; - - for (toc = 0; toc < fileHeader->ntoc; toc++) - { - if (fileHeader->tocstoc.type != XCURSOR_IMAGE_TYPE) - continue; - thisSize = fileHeader->tocstoc.subtype; - if (thisSize != size) - continue; - if (!count) - break; - count--; - } - if (toc == fileHeader->ntoc) - return -1; - return toc; -} + unsigned int n; + int nsizes = 0; + uint32_t best_size = 0; + uint32_t this_size; -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; -} + if (!file_header || !nsizesp) + return 0; -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->imagesimages->nimage = _XcursorReadImage (file, fileHeader, - toc); - if (!images->imagesimages->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->tocsn.type != XCURSOR_IMAGE_TYPE) + continue; + this_size = file_header->tocsn.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) +xcursor_find_image_toc(struct xcursor_file_header *file_header, + uint32_t size, int count) { - FILE *f = file->closure; - return fread (buf, 1, len, f); -} + unsigned int toc; + uint32_t this_size; -static int -_XcursorStdioFileWrite (XcursorFile *file, unsigned char *buf, int len) -{ - 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->tocstoc.type != XCURSOR_IMAGE_TYPE) + continue; + this_size = file_header->tocstoc.subtype; + if (this_size != size) + continue; + if (!count) + break; + count--; + } + if (toc == file_header->ntoc) + return -1; + return toc; } -static void -_XcursorStdioFileInitialize (FILE *stdfile, XcursorFile *file) +static struct xcursor_image * +xcursor_read_image(FILE *file, + struct xcursor_file_header *file_header, + int toc) { - file->closure = stdfile; - file->read = _XcursorStdioFileRead; - file->write = _XcursorStdioFileWrite; - file->seek = _XcursorStdioFileSeek; + 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 XcursorImages * -XcursorFileLoadImages (FILE *file, int size) +static struct xcursor_images * +xcursor_xc_file_load_images(FILE *file, int size) { - XcursorFile f; - - if (!file) - return NULL; - - _XcursorStdioFileInitialize (file, &f); - return XcursorXcFileLoadImages (&f, 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->imagesimages->nimage = xcursor_read_image(file, file_header, + toc); + if (!images->imagesimages->nimage) + break; + images->nimage++; + } + xcursor_file_header_destroy(file_header); + if (images->nimage != nsize) { + xcursor_images_destroy(images); + images = NULL; + } + return images; } /* @@ -634,292 +504,200 @@ * and must be freed by the caller. */ static char * -XcursorLibraryPath (void) +xcursor_library_path(void) { - 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 (path0 == '\0' || pathpathlen - 1 != '/') - { - strcat (path, "/"); - pathlen++; - } - if (len == -1) - len = strlen (elt); - /* strip leading slashes */ - while (len && elt0 == '/') - { - elt++; - len--; - } - strncpy (path + pathlen, elt, len); - pathpathlen + len = '\0'; + 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_var0 != '/') + 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; } static char * -_XcursorBuildThemeDir (const char *dir, const char *theme) +xcursor_build_theme_dir(const char *dir, const char *theme) { - 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; - full0 = '\0'; - - if (home) - _XcursorAddPathElt (full, home, -1); - _XcursorAddPathElt (full, dir, dirlen); - _XcursorAddPathElt (full, theme, themelen); - return full; + 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; } static char * -_XcursorBuildFullname (const char *dir, const char *subdir, const char *file) +xcursor_build_fullname(const char *dir, const char *subdir, const char *file) { - char *full; - - if (!dir || !subdir || !file) - return NULL; - - full = malloc (strlen (dir) + 1 + strlen (subdir) + 1 + strlen (file) + 1); - if (!full) - return NULL; - full0 = '\0'; - _XcursorAddPathElt (full, dir, -1); - _XcursorAddPathElt (full, subdir, -1); - _XcursorAddPathElt (full, file, -1); - return full; + char *full; + size_t full_size; + + 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; } static const char * -_XcursorNextPath (const char *path) +xcursor_next_path(const char *path) { - char *colon = strchr (path, ':'); + char *colon = strchr(path, ':'); - if (!colon) - return NULL; - return colon + 1; + if (!colon) + return NULL; + return colon + 1; } -#define XcursorWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') -#define XcursorSep(c) ((c) == ';' || (c) == ',') +static bool +xcursor_white(char c) +{ + return c == ' ' || c == '\t' || c == '\n'; +} + +static bool +xcursor_sep(char c) +{ + return c == ';' || c == ','; +} static char * -_XcursorThemeInherits (const char *full) +xcursor_theme_inherits(const char *full) { - char line8192; - 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; + 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; l++; - while (*l == ' ') l++; - result = malloc (strlen (l) + 1); - if (result) - { - r = result; - while (*l) - { - while (XcursorSep(*l) || XcursorWhite (*l)) l++; + while (*l == ' ') + l++; + result = malloc(strlen(l) + 1); + if (!result) + break; + + r = result; + while (*l) { + while (xcursor_sep(*l) || xcursor_white(*l)) + l++; if (!*l) - break; + break; if (r != result) - *r++ = ':'; - while (*l && !XcursorWhite(*l) && - !XcursorSep(*l)) - *r++ = *l++; - } - *r++ = '\0'; + *r++ = ':'; + while (*l && !xcursor_white(*l) && !xcursor_sep(*l)) + *r++ = *l++; } + *r++ = '\0'; + break; - } } - 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; -} + fclose(f); + free(line); -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; + return result; } static void load_all_cursors_from_dir(const char *path, int size, - void (*load_callback)(XcursorImages *, void *), + void (*load_callback)(struct xcursor_images *, void *), void *user_data) { FILE *f; DIR *dir = opendir(path); struct dirent *ent; char *full; - XcursorImages *images; + struct xcursor_images *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 = _XcursorBuildFullname(path, "", ent->d_name); + full = xcursor_build_fullname(path, "", ent->d_name); if (!full) continue; @@ -929,14 +707,14 @@ continue; } - images = XcursorFileLoadImages(f, size); + images = xcursor_xc_file_load_images(f, size); if (images) { - XcursorImagesSetName(images, ent->d_name); + images->name = strdup(ent->d_name); load_callback(images, user_data); } - fclose (f); + fclose(f); free(full); } @@ -946,26 +724,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 XcursorImages object + * inherited themes. Each cursor is loaded into an struct xcursor_images 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 XcursorImages + * will be called multiple times, with possibly different struct xcursor_images * object which have the same name. The user is expected to destroy the - * XcursorImages objects passed to the callback with - * XcursorImagesDestroy(). + * struct xcursor_images objects passed to the callback with + * xcursor_images_destroy(). * * \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 XcursorImages + * for each cursor loaded. The first parameter is the struct xcursor_images * 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)(XcursorImages *, void *), - void *user_data) + void (*load_callback)(struct xcursor_images *, void *), + void *user_data) { char *full, *dir; char *inherits = NULL; @@ -975,38 +753,31 @@ if (!theme) theme = "default"; - xcursor_path = XcursorLibraryPath(); + xcursor_path = xcursor_library_path(); for (path = xcursor_path; path; - path = _XcursorNextPath(path)) { - dir = _XcursorBuildThemeDir(path, theme); + path = xcursor_next_path(path)) { + dir = xcursor_build_theme_dir(path, theme); if (!dir) continue; - full = _XcursorBuildFullname(dir, "cursors", ""); - - if (full) { - load_all_cursors_from_dir(full, size, load_callback, - user_data); - free(full); - } + full = xcursor_build_fullname(dir, "cursors", ""); + 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); - } + full = xcursor_build_fullname(dir, "", "index.theme"); + inherits = xcursor_theme_inherits(full); + free(full); } free(dir); } - for (i = inherits; i; i = _XcursorNextPath(i)) + for (i = inherits; i; i = xcursor_next_path(i)) xcursor_load_theme(i, size, load_callback, user_data); - if (inherits) - free(inherits); - - free (xcursor_path); + free(inherits); + free(xcursor_path); }
View file
_service:tar_scm:wayland-1.20.0.tar.xz/cursor/xcursor.h -> _service:tar_scm:wayland-1.21.0.tar.gz/cursor/xcursor.h
Changed
@@ -28,40 +28,31 @@ #include <stdint.h> -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; +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 */ +}; /* * Other data structures exposed by the library API */ -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); +struct xcursor_images { + int nimage; /* number of images */ + struct xcursor_image **images; /* array of XcursorImage pointers */ + char *name; /* name used to load images */ +}; void -XcursorImagesDestroy (XcursorImages *images); +xcursor_images_destroy(struct xcursor_images *images); void xcursor_load_theme(const char *theme, int size, - void (*load_callback)(XcursorImages *, void *), - void *user_data); + void (*load_callback)(struct xcursor_images *, void *), + void *user_data); #endif
View file
_service:tar_scm:wayland-1.20.0.tar.xz/doc/doxygen/meson.build -> _service:tar_scm:wayland-1.21.0.tar.gz/doc/doxygen/meson.build
Changed
@@ -13,7 +13,7 @@ doxygen_conf = configuration_data() doxygen_conf.set('VERSION', meson.project_version()) -doxygen_conf.set('top_builddir', meson.build_root()) +doxygen_conf.set('top_builddir', meson.project_build_root()) wayland_doxygen = configure_file( input: 'wayland.doxygen.in', output: 'wayland.doxygen', @@ -76,6 +76,7 @@ # 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: @@ -84,7 +85,7 @@ '--builddir=@OUTDIR@', '--section=@0@'.format(s_name), '--output-format=@0@'.format(f_name), - '--stamp=doc/doxygen/@0@.stamp'.format(t_name), + '--stamp=@0@'.format(stamp), wayland_doxygen, '@INPUT@', , @@ -97,13 +98,14 @@ 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=doc/doxygen/man3.stamp', + '--stamp=@0@'.format(stamp), wayland_doxygen, '@INPUT@', ,
View file
_service:tar_scm:wayland-1.20.0.tar.xz/doc/meson.build -> _service:tar_scm:wayland-1.21.0.tar.gz/doc/meson.build
Changed
@@ -1,3 +1,7 @@ +if not get_option('libraries') + error('-Ddocumentation=true requires -Dlibraries=true') +endif + dot = find_program('dot') doxygen = find_program('doxygen') xsltproc = find_program('xsltproc') @@ -18,7 +22,7 @@ endif manpage_xsl = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl' -cmd = run_command(xsltproc, '--nonet', manpage_xsl) +cmd = run_command(xsltproc, '--nonet', manpage_xsl, check: false) if cmd.returncode() != 0 error('The style sheet for man pages providing "@0@" was not found.'.format(manpage_xsl)) endif
View file
_service:tar_scm:wayland-1.20.0.tar.xz/doc/publican/meson.build -> _service:tar_scm:wayland-1.21.0.tar.gz/doc/publican/meson.build
Changed
@@ -7,6 +7,7 @@ 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',
View file
_service:tar_scm:wayland-1.20.0.tar.xz/doc/publican/sources/Protocol.xml -> _service:tar_scm:wayland-1.21.0.tar.gz/doc/publican/sources/Protocol.xml
Changed
@@ -149,9 +149,9 @@ <term>string</term> <listitem> <para> - Starts with an unsigned 32-bit length, followed by the - string contents, including terminating null byte, then padding - to a 32-bit boundary. + 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. </para> </listitem> </varlistentry> @@ -194,6 +194,21 @@ </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">
View file
_service:tar_scm:wayland-1.20.0.tar.xz/egl/meson.build -> _service:tar_scm:wayland-1.21.0.tar.gz/egl/meson.build
Changed
@@ -11,7 +11,7 @@ executable('wayland-egl-abi-check', 'wayland-egl-abi-check.c') -nm_path = find_program('nm').path() +nm_path = find_program('nm').full_path() test( 'wayland-egl symbols check',
View file
_service:tar_scm:wayland-1.20.0.tar.xz/meson.build -> _service:tar_scm:wayland-1.21.0.tar.gz/meson.build
Changed
@@ -1,11 +1,12 @@ project( 'wayland', 'c', - version: '1.20.0', + version: '1.21.0', license: 'MIT', - meson_version: '>= 0.52.1', + meson_version: '>= 0.56.0', default_options: 'warning_level=2', - 'buildtype=debugoptimized' + 'buildtype=debugoptimized', + 'c_std=c99', ) wayland_version = meson.project_version().split('.') @@ -14,6 +15,12 @@ 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', @@ -79,7 +86,7 @@ foreach d: decls - if not cc.has_header_symbol(d'header', d'symbol', dependencies: epoll_dep) + if not cc.has_header_symbol(d'header', d'symbol', dependencies: epoll_dep, args: cc_args) error('@0@ is needed to compile Wayland libraries'.format(d'symbol')) endif endforeach @@ -87,7 +94,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) + if not cc.has_function('clock_gettime', prefix: '#include <time.h>', dependencies: rt_dep, args: cc_args) error('clock_gettime not found') endif endif @@ -111,12 +118,12 @@ if get_option('libraries') subdir('cursor') subdir('egl') - if get_option('tests') - subdir('tests') - endif - if get_option('documentation') - subdir('doc') - endif +endif +if get_option('tests') + subdir('tests') +endif +if get_option('documentation') + subdir('doc') endif if get_option('scanner')
View file
_service:tar_scm:wayland-1.20.0.tar.xz/meson_options.txt -> _service:tar_scm:wayland-1.21.0.tar.gz/meson_options.txt
Changed
@@ -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',
View file
_service:tar_scm:wayland-1.20.0.tar.xz/protocol/wayland.xml -> _service:tar_scm:wayland-1.21.0.tar.gz/protocol/wayland.xml
Changed
@@ -258,6 +258,12 @@ 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> @@ -271,8 +277,8 @@ Clients can create wl_shm_pool objects using the create_pool request. - At connection setup time, the wl_shm object emits one or more - format events to inform clients about the valid pixel formats + On binding the wl_shm object one or more format events + are emitted to inform clients about the valid pixel formats that can be used for buffers. </description> @@ -890,7 +896,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> @@ -1051,7 +1057,8 @@ a basic surface. Note! This protocol is deprecated and not intended for production use. - For desktop-style user interfaces, use xdg_shell. + For desktop-style user interfaces, use xdg_shell. Compositors and clients + should not implement this interface. </description> <enum name="error"> @@ -1781,7 +1788,7 @@ </request> </interface> - <interface name="wl_seat" version="7"> + <interface name="wl_seat" version="8"> <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 @@ -1914,7 +1921,7 @@ </interface> - <interface name="wl_pointer" version="7"> + <interface name="wl_pointer" version="8"> <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 @@ -2214,6 +2221,9 @@ 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 @@ -2221,7 +2231,8 @@ 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. + events. A wl_pointer.frame must not contain more than one axis_discrete + event per axis type. This event is optional; continuous scrolling devices like two-finger scrolling on touchpads do not have discrete @@ -2239,9 +2250,37 @@ <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="7"> + <interface name="wl_keyboard" version="8"> <description summary="keyboard input device"> The wl_keyboard interface represents one or more keyboards associated with a seat. @@ -2255,7 +2294,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; to determine the xkb keycode, clients must add 8 to the key event keycode"/> + summary="libxkbcommon compatible, null-terminated string; to determine the xkb keycode, clients must add 8 to the key event keycode"/> </enum> <event name="keymap"> @@ -2368,7 +2407,7 @@ </event> </interface> - <interface name="wl_touch" version="7"> + <interface name="wl_touch" version="8"> <description summary="touchscreen input device"> The wl_touch interface represents a touchscreen associated with a seat.
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/connection.c -> _service:tar_scm:wayland-1.21.0.tar.gz/src/connection.c
Changed
@@ -231,7 +231,7 @@ } static void -build_cmsg(struct wl_ring_buffer *buffer, char *data, int *clen) +build_cmsg(struct wl_ring_buffer *buffer, char *data, size_t *clen) { struct cmsghdr *cmsg; size_t size; @@ -289,9 +289,10 @@ wl_connection_flush(struct wl_connection *connection) { struct iovec iov2; - struct msghdr msg; + struct msghdr msg = {0}; char cmsgCLEN; - int len = 0, count, clen; + int len = 0, count; + size_t clen; uint32_t tail; if (!connection->want_flush) @@ -303,13 +304,10 @@ 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, @@ -568,10 +566,10 @@ if (size) { *num_arrays = wl_message_count_arrays(message); - closure = malloc(sizeof *closure + size + + closure = zalloc(sizeof *closure + size + *num_arrays * sizeof(struct wl_array)); } else { - closure = malloc(sizeof *closure); + closure = zalloc(sizeof *closure); } if (!closure) { @@ -810,10 +808,12 @@ } if (wl_map_reserve_new(objects, id) < 0) { - wl_log("not a valid new object id (%u), " - "message %s(%s)\n", - id, message->name, message->signature); - errno = EINVAL; + if (errno == EINVAL) { + wl_log("not a valid new object id (%u), " + "message %s(%s)\n", id, + message->name, + message->signature); + } goto err; } @@ -1272,11 +1272,18 @@ 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(stderr, "%7u.%03u %s%s%s@%u.%s(", + fprintf(f, "%7u.%03u %s%s%s@%u.%s(", time / 1000, time % 1000, discarded ? "discarded " : "", send ? " -> " : "", @@ -1286,41 +1293,41 @@ for (i = 0; i < closure->count; i++) { signature = get_next_argument(signature, &arg); if (i > 0) - fprintf(stderr, ", "); + fprintf(f, ", "); switch (arg.type) { case 'u': - fprintf(stderr, "%u", closure->argsi.u); + fprintf(f, "%u", closure->argsi.u); break; case 'i': - fprintf(stderr, "%d", closure->argsi.i); + fprintf(f, "%d", closure->argsi.i); break; case 'f': /* The magic number 390625 is 1e8 / 256 */ if (closure->argsi.f >= 0) { - fprintf(stderr, "%d.%08d", + fprintf(f, "%d.%08d", closure->argsi.f / 256, 390625 * (closure->argsi.f % 256)); } else { - fprintf(stderr, "-%d.%08d", + fprintf(f, "-%d.%08d", closure->argsi.f / -256, -390625 * (closure->argsi.f % 256)); } break; case 's': if (closure->argsi.s) - fprintf(stderr, "\"%s\"", closure->argsi.s); + fprintf(f, "\"%s\"", closure->argsi.s); else - fprintf(stderr, "nil"); + fprintf(f, "nil"); break; case 'o': if (closure->argsi.o) - fprintf(stderr, "%s@%u", + fprintf(f, "%s@%u", closure->argsi.o->interface->name, closure->argsi.o->id); else - fprintf(stderr, "nil"); + fprintf(f, "nil"); break; case 'n': if (n_parse) @@ -1328,25 +1335,30 @@ else nval = closure->argsi.n; - fprintf(stderr, "new id %s@", + fprintf(f, "new id %s@", (closure->message->typesi) ? closure->message->typesi->name : "unknown"); if (nval != 0) - fprintf(stderr, "%u", nval); + fprintf(f, "%u", nval); else - fprintf(stderr, "nil"); + fprintf(f, "nil"); break; case 'a': - fprintf(stderr, "array%zu", closure->argsi.a->size); + fprintf(f, "array%zu", closure->argsi.a->size); break; case 'h': - fprintf(stderr, "fd %d", closure->argsi.h); + fprintf(f, "fd %d", closure->argsi.h); break; } } - fprintf(stderr, ")\n"); + fprintf(f, ")\n"); + + if (fclose(f) == 0) { + fprintf(stderr, "%s", buffer); + free(buffer); + } } static int
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/event-loop.c -> _service:tar_scm:wayland-1.21.0.tar.gz/src/event-loop.c
Changed
@@ -179,7 +179,7 @@ { struct wl_event_source_fd *source; - source = malloc(sizeof *source); + source = zalloc(sizeof *source); if (source == NULL) return NULL; @@ -568,7 +568,7 @@ if (wl_timer_heap_ensure_timerfd(&loop->timers) < 0) return NULL; - source = malloc(sizeof *source); + source = zalloc(sizeof *source); if (source == NULL) return NULL; @@ -718,7 +718,7 @@ struct wl_event_source_signal *source; sigset_t mask; - source = malloc(sizeof *source); + source = zalloc(sizeof *source); if (source == NULL) return NULL; @@ -775,7 +775,7 @@ { struct wl_event_source_idle *source; - source = malloc(sizeof *source); + source = zalloc(sizeof *source); if (source == NULL) return NULL; @@ -885,7 +885,7 @@ { struct wl_event_loop *loop; - loop = malloc(sizeof *loop); + loop = zalloc(sizeof *loop); if (loop == NULL) return NULL;
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/meson.build -> _service:tar_scm:wayland-1.21.0.tar.gz/src/meson.build
Changed
@@ -1,3 +1,7 @@ +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_version0.to_int()) @@ -67,11 +71,15 @@ , 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_pkgconfig_variable('wayland_scanner')) + wayland_scanner_for_build = find_program(scanner_dep.get_variable(pkgconfig: 'wayland_scanner')) else wayland_scanner_for_build = wayland_scanner endif
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/wayland-client.c -> _service:tar_scm:wayland-1.21.0.tar.gz/src/wayland-client.c
Changed
@@ -343,7 +343,7 @@ { struct wl_event_queue *queue; - queue = malloc(sizeof *queue); + queue = zalloc(sizeof *queue); if (queue == NULL) return NULL; @@ -430,6 +430,10 @@ 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; } @@ -485,7 +489,10 @@ proxy->refcount = 1; proxy->version = factory->version; - wl_map_insert_at(&display->objects, 0, id, proxy); + if (wl_map_insert_at(&display->objects, 0, id, proxy) == -1) { + free(proxy); + return NULL; + } return proxy; } @@ -1069,8 +1076,8 @@ path_is_absolute = name0 == '/'; runtime_dir = getenv("XDG_RUNTIME_DIR"); - if (!runtime_dir && !path_is_absolute) { - wl_log("error: XDG_RUNTIME_DIR not set in the environment.\n"); + if (((!runtime_dir || runtime_dir0 != '/') && !path_is_absolute)) { + wl_log("error: XDG_RUNTIME_DIR is invalid or not set in the environment.\n"); /* to prevent programs reporting * "failed to create display: Success" */ errno = ENOENT; @@ -1155,11 +1162,16 @@ pthread_cond_init(&display->reader_cond, NULL); display->reader_count = 0; - wl_map_insert_new(&display->objects, 0, NULL); + if (wl_map_insert_at(&display->objects, 0, 0, NULL) == -1) + goto err_connection; - 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; @@ -2299,6 +2311,19 @@ * 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() @@ -2308,12 +2333,16 @@ 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
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/wayland-os.c -> _service:tar_scm:wayland-1.21.0.tar.gz/src/wayland-os.c
Changed
@@ -231,21 +231,22 @@ ssize_t new_size, int prot, int flags) { void *result; - /* - * We could try mapping a new block immediately after the current one + + /* 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 * 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. As this is not a - * performance-critical path, we always map a new region and copy the - * old data to the new region. + * have the bounds of the previous allocation. */ result = mmap(NULL, new_size, prot, flags, fd, 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. */ - } - } + if (result == MAP_FAILED) + return MAP_FAILED; + + if (munmap(old_data, *old_size) == 0) + *old_size = 0; + return result; }
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/wayland-private.h -> _service:tar_scm:wayland-1.21.0.tar.gz/src/wayland-private.h
Changed
@@ -45,6 +45,7 @@ #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 {
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/wayland-server-core.h -> _service:tar_scm:wayland-1.21.0.tar.gz/src/wayland-server-core.h
Changed
@@ -279,6 +279,9 @@ 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); @@ -481,6 +484,9 @@ 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); /*
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/wayland-server.c -> _service:tar_scm:wayland-1.21.0.tar.gz/src/wayland-server.c
Changed
@@ -578,6 +578,9 @@ * 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 @@ -1062,7 +1065,7 @@ if (debug && (strstr(debug, "server") || strstr(debug, "1"))) debug_server = 1; - display = malloc(sizeof *display); + display = zalloc(sizeof *display); if (display == NULL) return NULL; @@ -1205,6 +1208,10 @@ * 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 @@ -1238,7 +1245,7 @@ return NULL; } - global = malloc(sizeof *global); + global = zalloc(sizeof *global); if (global == NULL) return NULL; @@ -1252,11 +1259,12 @@ wl_list_insert(display->global_list.prev, &global->link); wl_list_for_each(resource, &display->registry_resource_list, link) - wl_resource_post_event(resource, - WL_REGISTRY_GLOBAL, - global->name, - global->interface->name, - global->version); + if (wl_global_is_visible(resource->client, global)) + wl_resource_post_event(resource, + WL_REGISTRY_GLOBAL, + global->name, + global->interface->name, + global->version); return global; } @@ -1294,8 +1302,9 @@ global->name); wl_list_for_each(resource, &display->registry_resource_list, link) - wl_resource_post_event(resource, WL_REGISTRY_GLOBAL_REMOVE, - global->name); + if (wl_global_is_visible(resource->client, global)) + wl_resource_post_event(resource, WL_REGISTRY_GLOBAL_REMOVE, + global->name); global->removed = true; } @@ -1315,6 +1324,20 @@ 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 @@ -1543,8 +1566,9 @@ if (name0 != '/') { runtime_dir = getenv("XDG_RUNTIME_DIR"); - if (!runtime_dir) { - wl_log("error: XDG_RUNTIME_DIR not set in the environment\n"); + if (!runtime_dir || runtime_dir0 != '/') { + wl_log("error: XDG_RUNTIME_DIR is invalid or not set in" + " the environment\n"); /* to prevent programs reporting * "failed to add socket: Success" */ @@ -1704,7 +1728,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 not set, then this function fails and returns -1. + * XDG_RUNTIME_DIR is invalid or 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. @@ -1822,12 +1846,17 @@ { struct wl_resource *resource; - resource = malloc(sizeof *resource); + resource = zalloc(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; @@ -1843,9 +1872,11 @@ resource->dispatcher = NULL; if (wl_map_insert_at(&client->objects, 0, id, resource) < 0) { - wl_resource_post_error(client->display_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "invalid new id %d", id); + if (errno == EINVAL) { + wl_resource_post_error(client->display_resource, + WL_DISPLAY_ERROR_INVALID_OBJECT, + "invalid new id %d", id); + } free(resource); return NULL; } @@ -1888,7 +1919,7 @@ { struct wl_protocol_logger *logger; - logger = malloc(sizeof *logger); + logger = zalloc(sizeof *logger); if (!logger) return NULL; @@ -2089,6 +2120,69 @@ 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 @@ -2238,12 +2332,16 @@ 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) { - wl_resource_post_error(client->display_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "invalid new id %d", - resource->object.id); + if (errno == EINVAL) { + wl_resource_post_error(client->display_resource, + WL_DISPLAY_ERROR_INVALID_OBJECT, + "invalid new id %d", + resource->object.id); + } return 0; }
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/wayland-shm.c -> _service:tar_scm:wayland-1.21.0.tar.gz/src/wayland-shm.c
Changed
@@ -65,10 +65,12 @@ 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; }; @@ -153,7 +155,9 @@ return; munmap(pool->data, pool->size); +#ifndef MREMAP_MAYMOVE close(pool->mmap_fd); +#endif free(pool); } @@ -223,7 +227,7 @@ return; } - buffer = malloc(sizeof *buffer); + buffer = zalloc(sizeof *buffer); if (buffer == NULL) { wl_client_post_no_memory(client); return; @@ -312,7 +316,7 @@ goto err_close; } - pool = malloc(sizeof *pool); + pool = zalloc(sizeof *pool); if (pool == NULL) { wl_client_post_no_memory(client); goto err_close; @@ -344,10 +348,14 @@ 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) {
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/wayland-util.c -> _service:tar_scm:wayland-1.21.0.tar.gz/src/wayland-util.c
Changed
@@ -24,6 +24,7 @@ * SOFTWARE. */ +#include <errno.h> #include <stdlib.h> #include <stdint.h> #include <stdio.h> @@ -197,6 +198,7 @@ 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; @@ -217,10 +219,26 @@ 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 (entry - start) + base; + return count + base; } int @@ -237,12 +255,21 @@ i -= WL_SERVER_ID_START; } + if (i > WL_MAP_MAX_OBJECTS) { + errno = ENOSPC; + return -1; + } + count = entries->size / sizeof *start; - if (count < i) + if (count < i) { + errno = EINVAL; return -1; + } - if (count == i) - wl_array_add(entries, sizeof *start); + if (count == i) { + if (!wl_array_add(entries, sizeof *start)) + return -1; + } start = entries->data; starti.data = data; @@ -259,30 +286,43 @@ struct wl_array *entries; if (i < WL_SERVER_ID_START) { - if (map->side == WL_MAP_CLIENT_SIDE) + if (map->side == WL_MAP_CLIENT_SIDE) { + errno = EINVAL; return -1; + } entries = &map->client_entries; } else { - if (map->side == WL_MAP_SERVER_SIDE) + if (map->side == WL_MAP_SERVER_SIDE) { + errno = EINVAL; return -1; + } entries = &map->server_entries; i -= WL_SERVER_ID_START; } - count = entries->size / sizeof *start; + if (i > WL_MAP_MAX_OBJECTS) { + errno = ENOSPC; + return -1; + } - if (count < i) + count = entries->size / sizeof *start; + if (count < i) { + errno = EINVAL; return -1; + } if (count == i) { - wl_array_add(entries, sizeof *start); + if (!wl_array_add(entries, sizeof *start)) + return -1; + start = entries->data; starti.data = NULL; } else { start = entries->data; if (starti.data != NULL) { + errno = EINVAL; return -1; } }
View file
_service:tar_scm:wayland-1.20.0.tar.xz/src/wayland-util.h -> _service:tar_scm:wayland-1.21.0.tar.gz/src/wayland-util.h
Changed
@@ -182,7 +182,7 @@ * For example, consider a protocol interface `foo`, marked as version `1`, with * two requests and one event. * - * \code + * \code{.xml} * <interface name="foo" version="1"> * <request name="a"></request> * <request name="b"></request>
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/compositor-introspection-test.c -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/compositor-introspection-test.c
Changed
@@ -40,7 +40,7 @@ require_xdg_runtime_dir(void) { char *val = getenv("XDG_RUNTIME_DIR"); - assert(val && "set $XDG_RUNTIME_DIR to run this test"); + assert(val && val0 == '/' && "set $XDG_RUNTIME_DIR to run this test"); return val; }
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/data/example-client.h -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/data/example-client.h
Changed
@@ -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
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/data/example.xml -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/data/example.xml
Changed
@@ -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>
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/display-test.c -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/display-test.c
Changed
@@ -24,6 +24,7 @@ * SOFTWARE. */ +#define _GNU_SOURCE #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -1005,9 +1006,16 @@ } } +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, - NULL + registry_handle_remove_filtered, }; static void @@ -1044,6 +1052,58 @@ } 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, ®istry_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) { uint32_t errorcode, id;
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/event-loop-test.c -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/event-loop-test.c
Changed
@@ -24,6 +24,7 @@ * SOFTWARE. */ +#define _GNU_SOURCE #include <stdlib.h> #include <stdint.h> #include <assert.h>
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/fixed-test.c -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/fixed-test.c
Changed
@@ -23,6 +23,7 @@ * SOFTWARE. */ +#define _GNU_SOURCE #include <stdlib.h> #include <stdio.h> #include <assert.h>
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/meson.build -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/meson.build
Changed
@@ -1,3 +1,7 @@ +if not get_option('libraries') + error('-Dtests=true requires -Dlibraries=true') +endif + test_runner = static_library( 'test-runner', sources: @@ -65,7 +69,7 @@ dependencies: test_runner_dep ) -if add_languages('cpp') +if add_languages('cpp', native: false) test( 'cpp-compile-test', executable( @@ -77,7 +81,7 @@ ) endif -sed_path = find_program('sed').path() +sed_path = find_program('sed').full_path() if get_option('scanner') test(
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/os-wrappers-test.c -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/os-wrappers-test.c
Changed
@@ -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, ...);
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/protocol-logger-test.c -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/protocol-logger-test.c
Changed
@@ -40,7 +40,7 @@ require_xdg_runtime_dir(void) { char *val = getenv("XDG_RUNTIME_DIR"); - assert(val && "set $XDG_RUNTIME_DIR to run this test"); + assert(val && val0 == '/' && "set $XDG_RUNTIME_DIR to run this test"); return val; }
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/sanity-test.c -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/sanity-test.c
Changed
@@ -174,7 +174,7 @@ { struct display *d = display_create(); - client_create_noarg(d, sanity_fd_leak); + client_create_noarg(d, sanity_fd_leak_exec); display_run(d); test_disable_coredumps();
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/signal-test.c -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/signal-test.c
Changed
@@ -115,3 +115,44 @@ 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); +}
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/socket-test.c -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/socket-test.c
Changed
@@ -51,7 +51,7 @@ require_xdg_runtime_dir(void) { char *val = getenv("XDG_RUNTIME_DIR"); - assert(val && "set $XDG_RUNTIME_DIR to run this test"); + assert(val && val0 == '/' && "set $XDG_RUNTIME_DIR to run this test"); return val; }
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/test-compositor.h -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/test-compositor.h
Changed
@@ -25,6 +25,7 @@ #include <stdint.h> #include <unistd.h> +#include <stdatomic.h> #include "wayland-server.h" #include "wayland-client.h" @@ -65,7 +66,7 @@ struct wl_display *wl_display; struct test_compositor *tc; - int display_stopped; + atomic_bool display_stopped; }; struct client *client_connect(void);
View file
_service:tar_scm:wayland-1.20.0.tar.xz/tests/test-runner.c -> _service:tar_scm:wayland-1.21.0.tar.gz/tests/test-runner.c
Changed
@@ -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 : "/tmp") < PATH_MAX) + (xrd_env && xrd_env0 == '/') ? 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 && "No XDG_RUNTIME_DIR set"); + assert(xrd_env && xrd_env0 == '/' && "No XDG_RUNTIME_DIR set"); /* rmdir may fail if some test didn't do clean up */ if (rmdir(xrd_env) == -1)
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2