[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

wayland: Changes to 'upstream-unstable'



Rebased ref, commits from common ancestor:
commit 6ef06ad06d0c32bff6bbd471a50a17bd7f92e0bc
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Sat Jul 13 01:30:45 2013 -0400

    Bump version to 1.2.0

diff --git a/configure.ac b/configure.ac
index 82e55e4..536df9e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,8 +1,8 @@
 AC_PREREQ([2.64])
 
 m4_define([wayland_major_version], [1])
-m4_define([wayland_minor_version], [1])
-m4_define([wayland_micro_version], [91])
+m4_define([wayland_minor_version], [2])
+m4_define([wayland_micro_version], [0])
 m4_define([wayland_version],
           [wayland_major_version.wayland_minor_version.wayland_micro_version])
 

commit e0579bfb61320653e3af74f5abb3bd50785c10b1
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Sat Jul 13 00:42:14 2013 -0400

    wayland-client: Handle potential NULL-deref
    
    Instead, return -1 on out-of-memory.  errno will be set to ENOMEM by
    the failing malloc.

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 34c8196..2887a40 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -662,6 +662,8 @@ wl_display_roundtrip(struct wl_display *display)
 
 	done = 0;
 	callback = wl_display_sync(display);
+	if (callback == NULL)
+		return -1;
 	wl_callback_add_listener(callback, &sync_listener, &done);
 	while (!done && ret >= 0)
 		ret = wl_display_dispatch(display);

commit 8bd93c5c9df2c40d01b7918c666edd68c0be1544
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Sat Jul 13 00:35:21 2013 -0400

    scanner: Fail more gracefully on out-of-memory
    
    Failing with an error message and error code is little nicer.  I doubt we'll
    hit this case much, but it makes the static analysis happy.

diff --git a/src/scanner.c b/src/scanner.c
index cc3a745..4aa70d1 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -127,13 +127,36 @@ struct parse_context {
 	unsigned int character_data_length;
 };
 
+static void *
+fail_on_null(void *p)
+{
+	if (p == NULL) {
+		fprintf(stderr, "wayland-scanner: out of memory\n");
+		exit(EXIT_FAILURE);
+	}
+
+	return p;
+}
+
+static void *
+xmalloc(size_t s)
+{
+	return fail_on_null(malloc(s));
+}
+
+static char *
+xstrdup(const char *s)
+{
+	return fail_on_null(strdup(s));
+}
+
 static char *
 uppercase_dup(const char *src)
 {
 	char *u;
 	int i;
 
-	u = strdup(src);
+	u = xstrdup(src);
 	for (i = 0; u[i]; i++)
 		u[i] = toupper(u[i]);
 	u[i] = '\0';
@@ -292,7 +315,7 @@ start_element(void *data, const char *element_name, const char **atts)
 		if (name == NULL)
 			fail(ctx, "no protocol name given");
 
-		ctx->protocol->name = strdup(name);
+		ctx->protocol->name = xstrdup(name);
 		ctx->protocol->uppercase_name = uppercase_dup(name);
 		ctx->protocol->description = NULL;
 	} else if (strcmp(element_name, "copyright") == 0) {
@@ -304,8 +327,8 @@ start_element(void *data, const char *element_name, const char **atts)
 		if (version == 0)
 			fail(ctx, "no interface version given");
 
-		interface = malloc(sizeof *interface);
-		interface->name = strdup(name);
+		interface = xmalloc(sizeof *interface);
+		interface->name = xstrdup(name);
 		interface->uppercase_name = uppercase_dup(name);
 		interface->version = version;
 		interface->description = NULL;
@@ -321,8 +344,8 @@ start_element(void *data, const char *element_name, const char **atts)
 		if (name == NULL)
 			fail(ctx, "no request name given");
 
-		message = malloc(sizeof *message);
-		message->name = strdup(name);
+		message = xmalloc(sizeof *message);
+		message->name = xstrdup(name);
 		message->uppercase_name = uppercase_dup(name);
 		wl_list_init(&message->arg_list);
 		message->arg_count = 0;
@@ -359,8 +382,8 @@ start_element(void *data, const char *element_name, const char **atts)
 		if (name == NULL)
 			fail(ctx, "no argument name given");
 
-		arg = malloc(sizeof *arg);
-		arg->name = strdup(name);
+		arg = xmalloc(sizeof *arg);
+		arg->name = xstrdup(name);
 
 		if (strcmp(type, "int") == 0)
 			arg->type = INT;
@@ -386,7 +409,7 @@ start_element(void *data, const char *element_name, const char **atts)
 		case NEW_ID:
 		case OBJECT:
 			if (interface_name)
-				arg->interface_name = strdup(interface_name);
+				arg->interface_name = xstrdup(interface_name);
 			else
 				arg->interface_name = NULL;
 			break;
@@ -408,7 +431,7 @@ start_element(void *data, const char *element_name, const char **atts)
 
 		arg->summary = NULL;
 		if (summary)
-			arg->summary = strdup(summary);
+			arg->summary = xstrdup(summary);
 
 		wl_list_insert(ctx->message->arg_list.prev, &arg->link);
 		ctx->message->arg_count++;
@@ -416,8 +439,8 @@ start_element(void *data, const char *element_name, const char **atts)
 		if (name == NULL)
 			fail(ctx, "no enum name given");
 
-		enumeration = malloc(sizeof *enumeration);
-		enumeration->name = strdup(name);
+		enumeration = xmalloc(sizeof *enumeration);
+		enumeration->name = xstrdup(name);
 		enumeration->uppercase_name = uppercase_dup(name);
 		enumeration->description = NULL;
 		wl_list_init(&enumeration->entry_list);
@@ -430,12 +453,12 @@ start_element(void *data, const char *element_name, const char **atts)
 		if (name == NULL)
 			fail(ctx, "no entry name given");
 
-		entry = malloc(sizeof *entry);
-		entry->name = strdup(name);
+		entry = xmalloc(sizeof *entry);
+		entry->name = xstrdup(name);
 		entry->uppercase_name = uppercase_dup(name);
-		entry->value = strdup(value);
+		entry->value = xstrdup(value);
 		if (summary)
-			entry->summary = strdup(summary);
+			entry->summary = xstrdup(summary);
 		else
 			entry->summary = NULL;
 		wl_list_insert(ctx->enumeration->entry_list.prev,
@@ -444,8 +467,8 @@ start_element(void *data, const char *element_name, const char **atts)
 		if (summary == NULL)
 			fail(ctx, "description without summary");
 
-		description = malloc(sizeof *description);
-		description->summary = strdup(summary);
+		description = xmalloc(sizeof *description);
+		description->summary = xstrdup(summary);
 
 		if (ctx->message)
 			ctx->message->description = description;

commit 43f7268989d8feb4b57c0f17af96f8c4ca2e6dd0
Author: Mariusz Ceier <mceier+wayland@gmail.com>
Date:   Wed Jul 10 23:40:56 2013 +0200

    connection: Handle empty signature and signature with just a version.
    
    Functions like wl_argument_from_va_list expect from get_next_argument,
    to initialize details->type but when the signature is empty or contains
    only version (like in desktop-shell-protocol.c in weston) it is left
    uninitialized.
    
    This patch fixes it, by initializing details->type with '\0' value,
    signaling end of arguments.
    
    Signed-off-by: Mariusz Ceier <mceier+wayland@gmail.com>

diff --git a/src/connection.c b/src/connection.c
index 2ca9bce..9bb850c 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -419,6 +419,7 @@ get_next_argument(const char *signature, struct argument_details *details)
 			details->nullable = 1;
 		}
 	}
+	details->type = '\0';
 	return signature;
 }
 

commit 3f3671e92e5c6e7e6e7a4b22371b1cccb7de8ca2
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Jul 9 19:27:08 2013 -0400

    Bump version to 1.1.91

diff --git a/configure.ac b/configure.ac
index 72ab1f9..82e55e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_PREREQ([2.64])
 
 m4_define([wayland_major_version], [1])
 m4_define([wayland_minor_version], [1])
-m4_define([wayland_micro_version], [90])
+m4_define([wayland_micro_version], [91])
 m4_define([wayland_version],
           [wayland_major_version.wayland_minor_version.wayland_micro_version])
 

commit 7100a5e0bb07d77f1700abe53968ffc5ba3749ce
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Jul 9 19:18:10 2013 -0400

    Replace two remaining wl_display_add_gloavl() occurences

diff --git a/src/wayland-shm.c b/src/wayland-shm.c
index 0d3c95c..1699058 100644
--- a/src/wayland-shm.c
+++ b/src/wayland-shm.c
@@ -258,7 +258,7 @@ bind_shm(struct wl_client *client,
 WL_EXPORT int
 wl_display_init_shm(struct wl_display *display)
 {
-	if (!wl_display_add_global(display, &wl_shm_interface, NULL, bind_shm))
+	if (!wl_global_create(display, &wl_shm_interface, 1, NULL, bind_shm))
 		return -1;
 
 	return 0;
diff --git a/tests/queue-test.c b/tests/queue-test.c
index 3abb71f..87147c1 100644
--- a/tests/queue-test.c
+++ b/tests/queue-test.c
@@ -266,8 +266,9 @@ TEST(queue)
 	}
 
 	for (i = 0; i < ARRAY_LENGTH(dummy_interfaces); i++)
-		wl_display_add_global(display.display, dummy_interfaces[i],
-				      NULL, dummy_bind);
+		wl_global_create(display.display, dummy_interfaces[i],
+				 dummy_interfaces[i]->version,
+				 NULL, dummy_bind);
 
 	ret = wl_display_add_socket(display.display, SOCKET_NAME);
 	assert(ret == 0);

commit 93d888aec6331ce30e61188cc00ab3dc9f137efb
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Jul 9 18:59:11 2013 -0400

    wayland-server: Don't close display fd in fatal error handler
    
    We can't do that there, we have to make sure it stays a valid fd until
    the application calls wl_display_disconnect().  Otherwise the application
    may end up poll()ing on a stale or wrong fd in case another part of the
    application (or another thread) triggered a fatal error.

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 7bd7f0d..34c8196 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -107,8 +107,6 @@ display_fatal_error(struct wl_display *display, int error)
 		error = 1;
 
 	display->last_error = error;
-	close(display->fd);
-	display->fd = -1;
 
 	wl_list_for_each(iter, &display->event_queue_list, link)
 		pthread_cond_broadcast(&iter->cond);
@@ -612,8 +610,7 @@ wl_display_disconnect(struct wl_display *display)
 	wl_event_queue_release(&display->queue);
 	pthread_mutex_destroy(&display->mutex);
 	pthread_cond_destroy(&display->reader_cond);
-	if (display->fd > 0)
-		close(display->fd);
+	close(display->fd);
 
 	free(display);
 }

commit becca5fcf7a69e5e7b2d287a8a24d93d9d29fa5a
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Jul 9 17:55:45 2013 -0400

    wayland-server: Return 0 from read_events() in case of EAGAIN
    
    Getting no data from the socket is not an error condition.  This may
    happen in case of calling prepare_read() and then read_events() with
    no other pending readers and no data in the socket.  In general,
    read_events() may not queue up events in the given event queue.  From
    a given threads point of view it doesn't matter whether events were
    read and put in a different event queue or no events were read at all.

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 45aa372..7bd7f0d 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -873,8 +873,10 @@ read_events(struct wl_display *display)
 	if (display->reader_count == 0) {
 		total = wl_connection_read(display->connection);
 		if (total == -1) {
-			if (errno != EAGAIN)
-				display_fatal_error(display, errno);
+			if (errno == EAGAIN)
+				return 0;
+
+			display_fatal_error(display, errno);
 			return -1;
 		} else if (total == 0) {
 			/* The compositor has closed the socket. This

commit 12cea9559313c3503a7a321e684e3ef1ec7a6e49
Author: Neil Roberts <neil@linux.intel.com>
Date:   Tue Jul 9 14:10:45 2013 +0100

    wayland-client: Treat EOF when reading the wayland socket as an error
    
    If EOF is encountered while reading from the Wayland socket, make
    wl_display_read_events() return -1 so that it will be treated as an
    error. The documentation for this function states that it will set
    errno when there is an error so it additionally makes up an errno of
    EPIPE.
    
    If we don't do this then when the compositor quits the Wayland socket
    will be become ready for reading but wl_display_dispatch will do
    nothing which typically makes the application take up 100% CPU. In
    particular eglSwapBuffers will likely get stuck in an infinite busy
    loop because it repeatedly calls wl_display_dispatch_queue while it
    waits for the frame callback.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=703892

diff --git a/src/wayland-client.c b/src/wayland-client.c
index cb091ab..45aa372 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -876,7 +876,15 @@ read_events(struct wl_display *display)
 			if (errno != EAGAIN)
 				display_fatal_error(display, errno);
 			return -1;
+		} else if (total == 0) {
+			/* The compositor has closed the socket. This
+			 * should be considered an error so we'll fake
+			 * an errno */
+			errno = EPIPE;
+			display_fatal_error(display, errno);
+			return -1;
 		}
+
 		for (rem = total; rem >= 8; rem -= size) {
 			size = queue_event(display, rem);
 			if (size == -1) {

commit 4cffa0fd61fde7760f2506b154b2af7d24b8c25f
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Mon Jul 8 18:45:41 2013 -0400

    wayland-server: Add wl_global_create/destroy()
    
    This patch introduces wl_global_create() and wl_global_destroy() as
    replacements for wl_display_add_global() and wl_display_remove_global().
    The add/remove_global API did not allow a compositor to indicate
    the implemented version of a global, it just took the version from
    the interface meta data.  The problem is that the meta data
    (which lives in libwayland-server.so) can get out of sync with a
    compositor implementation.  The compositor will then advertise a
    higher version of a global than what it actually implements.
    
    The new API lets a compositor pass in a version when it registers
    a global, which solves the problem.  The add/remove API is deprecated
    with this patch and will be removed.

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 32310b1..0a6e112 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -95,8 +95,10 @@ struct wl_display {
 };
 
 struct wl_global {
+	struct wl_display *display;
 	const struct wl_interface *interface;
 	uint32_t name;
+	uint32_t version;
 	void *data;
 	wl_global_bind_func_t bind;
 	struct wl_list link;
@@ -589,7 +591,8 @@ registry_bind(struct wl_client *client,
 		if (global->name == name)
 			break;
 
-	if (&global->link == &display->global_list)
+	if (&global->link == &display->global_list ||
+	    global->version < version)
 		wl_resource_post_error(resource,
 				       WL_DISPLAY_ERROR_INVALID_OBJECT,
 				       "invalid global %d", name);
@@ -652,7 +655,7 @@ display_get_registry(struct wl_client *client,
 				       WL_REGISTRY_GLOBAL,
 				       global->name,
 				       global->interface->name,
-				       global->interface->version);
+				       global->version);
 }
 
 static const struct wl_display_interface display_interface = {
@@ -714,8 +717,8 @@ wl_display_create(void)
 	display->id = 1;
 	display->serial = 0;
 
-	if (!wl_display_add_global(display, &wl_display_interface, 
-				   display, bind_display)) {
+	if (!wl_global_create(display, &wl_display_interface, 1,
+			      display, bind_display)) {
 		wl_event_loop_destroy(display->loop);
 		free(display);
 		return NULL;
@@ -749,19 +752,27 @@ wl_display_destroy(struct wl_display *display)
 }
 
 WL_EXPORT struct wl_global *
-wl_display_add_global(struct wl_display *display,
-		      const struct wl_interface *interface,
-		      void *data, wl_global_bind_func_t bind)
+wl_global_create(struct wl_display *display,
+		 const struct wl_interface *interface, int version,
+		 void *data, wl_global_bind_func_t bind)
 {
 	struct wl_global *global;
 	struct wl_resource *resource;
 
+	if (interface->version < version) {
+		wl_log("wl_global_create: implemented version higher "
+		       "than interface version%m\n");
+		return NULL;
+	}
+
 	global = malloc(sizeof *global);
 	if (global == NULL)
 		return NULL;
 
+	global->display = display;
 	global->name = display->id++;
 	global->interface = interface;
+	global->version = version;
 	global->data = data;
 	global->bind = bind;
 	wl_list_insert(display->global_list.prev, &global->link);
@@ -771,14 +782,15 @@ wl_display_add_global(struct wl_display *display,
 				       WL_REGISTRY_GLOBAL,
 				       global->name,
 				       global->interface->name,
-				       global->interface->version);
+				       global->version);
 
 	return global;
 }
 
 WL_EXPORT void
-wl_display_remove_global(struct wl_display *display, struct wl_global *global)
+wl_global_destroy(struct wl_global *global)
 {
+	struct wl_display *display = global->display;
 	struct wl_resource *resource;
 
 	wl_list_for_each(resource, &display->registry_resource_list, link)
@@ -1139,3 +1151,26 @@ wl_client_new_object(struct wl_client *client,
 
 	return resource;
 }
+
+struct wl_global *
+wl_display_add_global(struct wl_display *display,
+		      const struct wl_interface *interface,
+		      void *data, wl_global_bind_func_t bind) WL_DEPRECATED;
+
+WL_EXPORT struct wl_global *
+wl_display_add_global(struct wl_display *display,
+		      const struct wl_interface *interface,
+		      void *data, wl_global_bind_func_t bind)
+{
+	return wl_global_create(display, interface, interface->version, data, bind);
+}
+
+void
+wl_display_remove_global(struct wl_display *display,
+			 struct wl_global *global) WL_DEPRECATED;
+
+WL_EXPORT void
+wl_display_remove_global(struct wl_display *display, struct wl_global *global)
+{
+	wl_global_destroy(global);
+}
diff --git a/src/wayland-server.h b/src/wayland-server.h
index 0a798f4..9e16d0e 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -99,14 +99,6 @@ void wl_display_flush_clients(struct wl_display *display);
 typedef void (*wl_global_bind_func_t)(struct wl_client *client, void *data,
 				      uint32_t version, uint32_t id);
 
-struct wl_global *wl_display_add_global(struct wl_display *display,
-					const struct wl_interface *interface,
-					void *data,
-					wl_global_bind_func_t bind);
-
-void wl_display_remove_global(struct wl_display *display,
-			      struct wl_global *global);
-
 uint32_t wl_display_get_serial(struct wl_display *display);
 uint32_t wl_display_next_serial(struct wl_display *display);
 
@@ -115,6 +107,12 @@ void wl_display_add_destroy_listener(struct wl_display *display,
 struct wl_listener *wl_display_get_destroy_listener(struct wl_display *display,
 						    wl_notify_func_t notify);
 
+struct wl_global *wl_global_create(struct wl_display *display,
+				   const struct wl_interface *interface,
+				   int version,
+				   void *data, wl_global_bind_func_t bind);
+void wl_global_destroy(struct wl_global *global);
+
 struct wl_client *wl_client_create(struct wl_display *display, int fd);
 void wl_client_destroy(struct wl_client *client);
 void wl_client_flush(struct wl_client *client);
@@ -213,6 +211,16 @@ wl_client_new_object(struct wl_client *client,
 		     const struct wl_interface *interface,
 		     const void *implementation, void *data) WL_DEPRECATED;
 
+struct wl_global *
+wl_display_add_global(struct wl_display *display,
+		      const struct wl_interface *interface,
+		      void *data,
+		      wl_global_bind_func_t bind) WL_DEPRECATED;
+
+void
+wl_display_remove_global(struct wl_display *display,
+			 struct wl_global *global) WL_DEPRECATED;
+
 #endif
 
 /*

commit 40fc79d5b095e330ab6f851e35ba54a65781679f
Author: Daiki Ueno <ueno@gnu.org>
Date:   Tue Jul 2 18:38:15 2013 +0900

    build: Add wayland-scanner.pc.
    
    To allow user program to include wayland-scanner.m4 in tarball, move
    the path variables from it into wayland-scanner.pc.

diff --git a/Makefile.am b/Makefile.am
index df6d4b3..ddf39d1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,6 +7,6 @@ SUBDIRS = src protocol $(doc_subdir) tests cursor
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
 aclocaldir = $(datadir)/aclocal
-aclocal_DATA = wayland-scanner.m4
+dist_aclocal_DATA = wayland-scanner.m4
 
 dist_pkgdata_DATA = wayland-scanner.mk
diff --git a/configure.ac b/configure.ac
index 7ca70da..72ab1f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -127,7 +127,6 @@ fi
 AM_CONDITIONAL([HAVE_PUBLICAN], [test "x$PUBLICAN" != "x"])
 
 AC_CONFIG_FILES([Makefile
-		 wayland-scanner.m4
 		 cursor/Makefile
 		 cursor/wayland-cursor.pc
 		 cursor/wayland-cursor-uninstalled.pc
@@ -138,8 +137,10 @@ AC_CONFIG_FILES([Makefile
 		 src/Makefile
 		 src/wayland-server-uninstalled.pc
 		 src/wayland-client-uninstalled.pc
+		 src/wayland-scanner-uninstalled.pc
 		 src/wayland-server.pc
 		 src/wayland-client.pc
+		 src/wayland-scanner.pc
 		 src/wayland-version.h
 		 protocol/Makefile
 		 tests/Makefile])
diff --git a/src/Makefile.am b/src/Makefile.am
index 4fa7425..4226f63 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,6 +57,9 @@ wayland_scanner_SOURCES =				\
 wayland_scanner_LDADD = $(EXPAT_LIBS) libwayland-util.la
 
 $(BUILT_SOURCES) : wayland-scanner
+
+scannerpkgconfigdir = $(datadir)/pkgconfig
+scannerpkgconfig_DATA = wayland-scanner.pc
 endif
 
 BUILT_SOURCES =					\
diff --git a/src/wayland-scanner-uninstalled.pc.in b/src/wayland-scanner-uninstalled.pc.in
new file mode 100644
index 0000000..8dcfef3
--- /dev/null
+++ b/src/wayland-scanner-uninstalled.pc.in
@@ -0,0 +1,6 @@
+pkgdatadir=@abs_top_srcdir@
+wayland_scanner=@abs_builddir@/wayland-scanner
+ 
+Name: Wayland Scanner
+Description: Wayland scanner (not installed)
+Version: @PACKAGE_VERSION@
diff --git a/src/wayland-scanner.pc.in b/src/wayland-scanner.pc.in
new file mode 100644
index 0000000..7b2a4c9
--- /dev/null
+++ b/src/wayland-scanner.pc.in
@@ -0,0 +1,9 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datarootdir=@datarootdir@
+pkgdatadir=@datadir@/@PACKAGE@
+wayland_scanner=@bindir@/wayland-scanner
+
+Name: Wayland Scanner
+Description: Wayland scanner
+Version: @WAYLAND_VERSION@
diff --git a/wayland-scanner.m4 b/wayland-scanner.m4
new file mode 100644
index 0000000..2b87c5f
--- /dev/null
+++ b/wayland-scanner.m4
@@ -0,0 +1,11 @@
+AC_DEFUN([WAYLAND_SCANNER_RULES], [
+    PKG_PROG_PKG_CONFIG
+
+    wayland_scanner=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
+    AC_SUBST([wayland_scanner])
+
+    wayland_scanner_rules=`$PKG_CONFIG --variable=pkgdatadir wayland-scanner`/wayland-scanner.mk
+    AC_SUBST_FILE([wayland_scanner_rules])
+
+    AC_SUBST([wayland_protocoldir], [$1])
+])
diff --git a/wayland-scanner.m4.in b/wayland-scanner.m4.in
deleted file mode 100644
index 29bc788..0000000
--- a/wayland-scanner.m4.in
+++ /dev/null
@@ -1,16 +0,0 @@
-AC_DEFUN([WAYLAND_SCANNER_RULES], [
-    wayland__prefix=${prefix}
-    wayland__exec_prefix=${exec_prefix}
-
-    prefix=@prefix@
-    exec_prefix=@exec_prefix@
-
-    AC_PATH_PROG([wayland_scanner], [wayland-scanner], [/bin/false],
-		 [@bindir@$PATH_SEPARATOR$PATH])
-    AC_SUBST_FILE([wayland_scanner_rules])
-    AC_SUBST([wayland_protocoldir], [$1])
-    wayland_scanner_rules=@datarootdir@/aclocal/wayland-scanner.mk
-
-    prefix=${wayland__prefix}
-    exec_prefix=${wayland__exec_prefix}
-])

commit 60fc83af6ea47bd6cca248a04aff5fb60115977a
Author: Daiki Ueno <ueno@gnu.org>
Date:   Tue Jul 2 18:38:14 2013 +0900

    build: Install wayland-scanner.mk under $(pkgdatadir).

diff --git a/Makefile.am b/Makefile.am
index 306d7b3..df6d4b3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,6 +7,6 @@ SUBDIRS = src protocol $(doc_subdir) tests cursor
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
 aclocaldir = $(datadir)/aclocal
-aclocal_DATA = wayland-scanner.m4 wayland-scanner.mk
+aclocal_DATA = wayland-scanner.m4
 
-EXTRA_DIST = wayland-scanner.mk
+dist_pkgdata_DATA = wayland-scanner.mk

commit 3cff4693ea2d547191a2d4270d9444da7df7d462
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Jul 2 16:59:44 2013 -0400

    wayland-server: Free non-legacy wl_resource structs during wl_client_destroy
    
    We need to free the non-legacy resources during client shutdown as well.

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 5410553..32310b1 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -422,11 +422,17 @@ static void
 destroy_resource(void *element, void *data)
 {
 	struct wl_resource *resource = element;
+	struct wl_client *client = resource->client;
+	uint32_t flags;
 
 	wl_signal_emit(&resource->destroy_signal, resource);
 
+	flags = wl_map_lookup_flags(&client->objects, resource->object.id);
 	if (resource->destroy)
 		resource->destroy(resource);
+
+	if (!(flags & WL_MAP_ENTRY_LEGACY))
+		free(resource);
 }
 
 WL_EXPORT void
@@ -438,9 +444,6 @@ wl_resource_destroy(struct wl_resource *resource)
 	id = resource->object.id;
 	destroy_resource(resource, NULL);
 
-	if (!(wl_map_lookup_flags(&client->objects, id) & WL_MAP_ENTRY_LEGACY))
-		free(resource);
-
 	if (id < WL_SERVER_ID_START) {
 		if (client->display_resource) {
 			wl_resource_queue_event(client->display_resource,

commit 477c7237e1f09695f37f062c2bb5520bc3a9ed4c
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Jul 2 16:57:45 2013 -0400

    wayland-server: Remove left-over double free in unbind_resource() helper

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 4efc270..5410553 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -620,7 +620,6 @@ static void
 unbind_resource(struct wl_resource *resource)
 {
 	wl_list_remove(&resource->link);
-	free(resource);
 }
 
 static void

commit c82a52a47e5e01246680b5d257fff7bc42cb48bf
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Jul 2 15:39:03 2013 -0400

    wayland-server: Remove error event posting from wl_resource_create
    
    The wl_client_add/new_object() functions sends out an NO_MEMORY error if
    the allocation fails.  This was convenient in a couple of places where
    that was all the error handling that was needed.  Unfortunately that
    looks like out-of-memory isn't handled at the call site and set a bad
    precedent for not cleaning up properly or not handling at all.
    
    As we're introducing wl_resource_create() as a replacement for those two
    functions, let's remove the automatic error event posting and require
    the caller to do that if necessary.
    
    This commit also introduces a new helper, wl_client_post_no_memory() to
    make it possible to send NO_MEMORY events from bind where we don't have
    a wl_resource.

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 33fdb20..4efc270 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -405,6 +405,13 @@ wl_client_get_object(struct wl_client *client, uint32_t id)
 }
 
 WL_EXPORT void
+wl_client_post_no_memory(struct wl_client *client)
+{
+	wl_resource_post_error(client->display_resource,
+			       WL_DISPLAY_ERROR_NO_MEMORY, "no memory");
+}
+
+WL_EXPORT void
 wl_resource_post_no_memory(struct wl_resource *resource)
 {
 	wl_resource_post_error(resource->client->display_resource,
@@ -599,6 +606,11 @@ display_sync(struct wl_client *client,
 	uint32_t serial;
 
 	callback = wl_resource_create(client, &wl_callback_interface, 1, id);
+	if (callback == NULL) {
+		wl_client_post_no_memory(client);
+		return;
+	}
+
 	serial = wl_display_get_serial(client->display);
 	wl_callback_send_done(callback, serial);
 	wl_resource_destroy(callback);
@@ -621,6 +633,11 @@ display_get_registry(struct wl_client *client,
 
 	registry_resource =
 		wl_resource_create(client, &wl_registry_interface, 1, id);
+	if (registry_resource == NULL) {
+		wl_client_post_no_memory(client);
+		return;
+	}
+
 	wl_resource_set_implementation(registry_resource,
 				       &registry_interface,
 				       display, unbind_resource);
@@ -655,6 +672,11 @@ bind_display(struct wl_client *client,
 
 	client->display_resource =
 		wl_resource_create(client, &wl_display_interface, 1, id);
+	if (client->display_resource == NULL) {
+		wl_client_post_no_memory(client);
+		return;
+	}
+
 	wl_resource_set_implementation(client->display_resource,
 				       &display_interface, display,
 				       destroy_client_display_resource);
@@ -1007,10 +1029,8 @@ wl_resource_create(struct wl_client *client,
 	struct wl_resource *resource;
 
 	resource = malloc(sizeof *resource);
-	if (resource == NULL) {
-		wl_resource_post_no_memory(client->display_resource);
+	if (resource == NULL)
 		return NULL;
-	}
 
 	if (id == 0)
 		id = wl_map_insert_new(&client->objects, 0, NULL);
@@ -1087,7 +1107,11 @@ wl_client_add_object(struct wl_client *client,
 	struct wl_resource *resource;
 
 	resource = wl_resource_create(client, interface, -1, id);
-	wl_resource_set_implementation(resource, implementation, data, NULL);
+	if (resource == NULL)
+		wl_client_post_no_memory(client);
+	else
+		wl_resource_set_implementation(resource,
+					       implementation, data, NULL);
 
 	return resource;
 }
@@ -1105,7 +1129,11 @@ wl_client_new_object(struct wl_client *client,
 	struct wl_resource *resource;
 
 	resource = wl_resource_create(client, interface, -1, 0);
-	wl_resource_set_implementation(resource, implementation, data, NULL);
+	if (resource == NULL)
+		wl_client_post_no_memory(client);
+	else
+		wl_resource_set_implementation(resource,
+					       implementation, data, NULL);
 
 	return resource;
 }
diff --git a/src/wayland-server.h b/src/wayland-server.h
index 4378983..0a798f4 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -128,6 +128,8 @@ struct wl_listener *wl_client_get_destroy_listener(struct wl_client *client,
 
 struct wl_resource *
 wl_client_get_object(struct wl_client *client, uint32_t id);
+void
+wl_client_post_no_memory(struct wl_client *client);
 
 struct wl_listener {
 	struct wl_list link;
diff --git a/src/wayland-shm.c b/src/wayland-shm.c
index dc9731b..0d3c95c 100644
--- a/src/wayland-shm.c
+++ b/src/wayland-shm.c
@@ -115,7 +115,7 @@ shm_pool_create_buffer(struct wl_client *client, struct wl_resource *resource,
 
 	buffer = malloc(sizeof *buffer);
 	if (buffer == NULL) {
-		wl_resource_post_no_memory(resource);
+		wl_client_post_no_memory(client);
 		return;
 	}
 
@@ -129,6 +129,13 @@ shm_pool_create_buffer(struct wl_client *client, struct wl_resource *resource,
 
 	buffer->resource =
 		wl_resource_create(client, &wl_buffer_interface, 1, id);
+	if (buffer->resource == NULL) {
+		wl_client_post_no_memory(client);
+		shm_pool_unref(pool);
+		free(buffer);
+		return;
+	}
+
 	wl_resource_set_implementation(buffer->resource,
 				       &shm_buffer_interface,
 				       buffer, destroy_buffer);
@@ -182,7 +189,7 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
 
 	pool = malloc(sizeof *pool);
 	if (pool == NULL) {
-		wl_resource_post_no_memory(resource);
+		wl_client_post_no_memory(client);
 		goto err_close;
 	}
 
@@ -207,8 +214,12 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
 
 	pool->resource =
 		wl_resource_create(client, &wl_shm_pool_interface, 1, id);
-	if (!pool->resource)
-		goto err_free;
+	if (!pool->resource) {
+		wl_client_post_no_memory(client);
+		munmap(pool->data, pool->size);
+		free(pool);
+		return;
+	}
 
 	wl_resource_set_implementation(pool->resource,
 				       &shm_pool_interface,
@@ -233,6 +244,11 @@ bind_shm(struct wl_client *client,
 	struct wl_resource *resource;
 
 	resource = wl_resource_create(client, &wl_shm_interface, 1, id);
+	if (!resource) {
+		wl_client_post_no_memory(client);
+		return;
+	}
+
 	wl_resource_set_implementation(resource, &shm_interface, data, NULL);
 
 	wl_shm_send_format(resource, WL_SHM_FORMAT_ARGB8888);
@@ -276,6 +292,11 @@ wl_shm_buffer_create(struct wl_client *client,
 
 	buffer->resource =
 		wl_resource_create(client, &wl_buffer_interface, 1, id);
+	if (buffer->resource == NULL) {
+		free(buffer);
+		return NULL;
+	}
+
 	wl_resource_set_implementation(buffer->resource,
 				       &shm_buffer_interface,
 				       buffer, destroy_buffer);

commit b5b11650081f7adb4866fcacd216d3bd83da5024
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Jul 2 14:34:42 2013 -0400

    wayland-server: Mark wl_client_add/new_object as deprecated

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 0933337..33fdb20 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -398,33 +398,6 @@ wl_client_get_credentials(struct wl_client *client,
 		*gid = client->ucred.gid;
 }
 


Reply to: