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

wayland: Changes to 'upstream-unstable'



 .gitignore                     |    1 
 configure.ac                   |    4 
 doc/doxygen/Makefile.am        |    6 +
 doc/doxygen/wayland.doxygen.in |    2 
 protocol/Makefile.am           |    2 
 protocol/wayland.xml           |   85 +++++++++++++++++++-
 src/connection.c               |    9 +-
 src/scanner.c                  |    6 -
 src/wayland-client.c           |  115 +++++++++++++++++++++++++---
 src/wayland-client.h           |    6 +
 src/wayland-client.pc.in       |    2 
 src/wayland-private.h          |   19 +---
 src/wayland-server.c           |   95 +++++++++++++++++++----
 src/wayland-server.h           |  115 ++++++++++++++++++++++++++++
 src/wayland-server.pc.in       |    2 
 src/wayland-shm.c              |   45 +++++++----
 src/wayland-util.h             |   85 ++++++++++++++++++++
 tests/Makefile.am              |    6 +
 tests/resources-test.c         |  167 +++++++++++++++++++++++++++++++++++++++++
 tests/signal-test.c            |  114 +++++++++++++++++++++++++++
 tests/test-runner.c            |   17 +++-
 21 files changed, 836 insertions(+), 67 deletions(-)

New commits:
commit dd32f32d3242ab33ae5e3c3c982240b7674cce00
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Oct 9 16:20:54 2013 -0700

    configure.ac: Bump version to 1.3

diff --git a/configure.ac b/configure.ac
index 3b79c54..fa924ae 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], [2])
-m4_define([wayland_micro_version], [92])
+m4_define([wayland_minor_version], [3])
+m4_define([wayland_micro_version], [0])
 m4_define([wayland_version],
           [wayland_major_version.wayland_minor_version.wayland_micro_version])
 

commit 8b7feb3ab253dbcdf7c650e150f88f59c06f1a47
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Mon Oct 7 21:36:31 2013 -0700

    scanner: Handle unrecognized invocation mode
    
    Print usage if we don't recognize the invocation mode.  Also fixes
    uninitialized variable warning.

diff --git a/src/scanner.c b/src/scanner.c
index d02d865..0fbaabd 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1178,6 +1178,8 @@ int main(int argc, char *argv[])
 		mode = SERVER_HEADER;
 	else if (strcmp(argv[1], "code") == 0)
 		mode = CODE;
+	else
+		usage(EXIT_FAILURE);
 
 	wl_list_init(&protocol.interface_list);
 	protocol.type_index = 0;
@@ -1210,7 +1212,7 @@ int main(int argc, char *argv[])
 
 	XML_ParserFree(ctx.parser);
 
-	switch(mode) {
+	switch (mode) {
 		case CLIENT_HEADER:
 			emit_header(&protocol, 0);
 			break;

commit 6017827c5c914e8a8a0af33fa713742bff4674de
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Oct 2 22:14:57 2013 -0700

    configure.ac: Bump version to 1.2.92

diff --git a/configure.ac b/configure.ac
index dec94f5..3b79c54 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], [2])
-m4_define([wayland_micro_version], [91])
+m4_define([wayland_micro_version], [92])
 m4_define([wayland_version],
           [wayland_major_version.wayland_minor_version.wayland_micro_version])
 

commit 8192cecd35c8c7dfe824978928fc349f509f2686
Author: Neil Roberts <neil@linux.intel.com>
Date:   Wed Sep 25 10:39:12 2013 +0100

    client: Fix handling display->reader_count if poll fails
    
    In wl_display_dispatch_queue, if poll fails then it would previously
    return immediately and leak a reference in display->reader_count. Then
    if the application ignores the error and tries to read again it will
    block forever. This can happen for example if the poll fails with
    EINTR which the application might consider to be a recoverable error.
    This patch makes it cancel the read so the reader_count will be
    decremented when poll fails.

diff --git a/src/wayland-client.c b/src/wayland-client.c
index d043459..e92317a 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -1210,8 +1210,10 @@ wl_display_dispatch_queue(struct wl_display *display,
 
 	pfd[0].fd = display->fd;
 	pfd[0].events = POLLIN;
-	if (poll(pfd, 1, -1) == -1)
+	if (poll(pfd, 1, -1) == -1) {
+		wl_display_cancel_read(display);
 		return -1;
+	}
 
 	pthread_mutex_lock(&display->mutex);
 

commit 3f32c25f7f928502b5c50aa140a52897baf28d50
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Sun Sep 22 14:12:26 2013 -0700

    configure.ac: Bump version to 1.2.91

diff --git a/configure.ac b/configure.ac
index 5acbeef..dec94f5 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], [2])
-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 3d4d939f29dfcb9928d456417e84220294509884
Author: Jason Ekstrand <jason@jlekstrand.net>
Date:   Fri Sep 20 08:27:06 2013 -0500

    Export the Wayland protocol XML file
    
    Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>

diff --git a/protocol/Makefile.am b/protocol/Makefile.am
index 08690b3..cc9cd1c 100644
--- a/protocol/Makefile.am
+++ b/protocol/Makefile.am
@@ -1 +1 @@
-EXTRA_DIST = wayland.xml
+dist_pkgdata_DATA = wayland.xml
diff --git a/src/wayland-client.pc.in b/src/wayland-client.pc.in
index e453018..eef61da 100644
--- a/src/wayland-client.pc.in
+++ b/src/wayland-client.pc.in
@@ -1,5 +1,7 @@
 prefix=@prefix@
 exec_prefix=@exec_prefix@
+datarootdir=@datarootdir@
+pkgdatadir=@datadir@/@PACKAGE@
 libdir=@libdir@
 includedir=@includedir@
 
diff --git a/src/wayland-server.pc.in b/src/wayland-server.pc.in
index 18a0b52..50dff53 100644
--- a/src/wayland-server.pc.in
+++ b/src/wayland-server.pc.in
@@ -1,5 +1,7 @@
 prefix=@prefix@
 exec_prefix=@exec_prefix@
+datarootdir=@datarootdir@
+pkgdatadir=@datadir@/@PACKAGE@
 libdir=@libdir@
 includedir=@includedir@
 

commit 8147e6edd0e22efdcb5ea56636bbff0fd7454b4d
Author: Marek Ch <mchqwerty@gmail.com>
Date:   Wed Sep 18 17:29:50 2013 +0200

    tests: add wl_resource tests

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3806cb6..9c673ae 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -11,7 +11,8 @@ TESTS =						\
 	sanity-test				\
 	socket-test				\
 	queue-test				\
-	signal-test
+	signal-test				\
+	resources-test
 
 check_PROGRAMS =				\
 	$(TESTS)				\
@@ -34,6 +35,7 @@ sanity_test_SOURCES = sanity-test.c $(test_runner_src)
 socket_test_SOURCES = socket-test.c $(test_runner_src)
 queue_test_SOURCES = queue-test.c $(test_runner_src)
 signal_test_SOURCES = signal-test.c $(test_runner_src)
+resources_test_SOURCES = resources-test.c $(test_runner_src)
 
 fixed_benchmark_SOURCES = fixed-benchmark.c
 
diff --git a/tests/resources-test.c b/tests/resources-test.c
new file mode 100644
index 0000000..d7a428a
--- /dev/null
+++ b/tests/resources-test.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright © 2013 Marek Chalupa
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include "wayland-server.h"
+#include "test-runner.h"
+
+TEST(create_resource_tst)
+{
+	struct wl_display *display;
+	struct wl_client *client;
+	struct wl_resource *res;
+	struct wl_list *link;
+	int s[2];
+	uint32_t id;
+
+	assert(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, s) == 0);
+	display = wl_display_create();
+	assert(display);
+	client = wl_client_create(display, s[0]);
+	assert(client);
+
+	res = wl_resource_create(client, &wl_display_interface, 4, 0);
+	assert(res);
+
+	/* setters/getters */
+	assert(wl_resource_get_version(res) == 4);
+
+	assert(client == wl_resource_get_client(res));
+	id = wl_resource_get_id(res);
+	assert(wl_client_get_object(client, id) == res);
+
+	link = wl_resource_get_link(res);
+	assert(link);
+	assert(wl_resource_from_link(link) == res);
+
+	wl_resource_set_user_data(res, (void *) 0xbee);
+	assert(wl_resource_get_user_data(res) == (void *) 0xbee);
+
+	wl_resource_destroy(res);
+	wl_client_destroy(client);
+	wl_display_destroy(display);
+	close(s[1]);
+}
+
+static void
+res_destroy_func(struct wl_resource *res)
+{
+	assert(res);
+
+	_Bool *destr = wl_resource_get_user_data(res);
+	*destr = 1;
+}
+
+static _Bool notify_called = 0;
+static void
+destroy_notify(struct wl_listener *l, void *data)
+{
+	assert(l && data);
+	notify_called = 1;
+}
+
+TEST(destroy_res_tst)
+{
+	struct wl_display *display;
+	struct wl_client *client;
+	struct wl_resource *res;
+	int s[2];
+	unsigned id;
+	struct wl_list *link;
+
+	_Bool destroyed = 0;
+	struct wl_listener destroy_listener = {
+		.notify = &destroy_notify
+	};
+
+	assert(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, s) == 0);
+	display = wl_display_create();
+	assert(display);
+	client = wl_client_create(display, s[0]);
+	assert(client);
+
+	res = wl_resource_create(client, &wl_display_interface, 4, 0);
+	assert(res);
+	wl_resource_set_implementation(res, NULL, &destroyed, res_destroy_func);
+	wl_resource_add_destroy_listener(res, &destroy_listener);
+
+	/* without implementation this should be ignored .. */
+	wl_resource_post_event(res, 0);
+
+	id = wl_resource_get_id(res);
+	link = wl_resource_get_link(res);
+	assert(link);
+
+	wl_resource_destroy(res);
+	assert(destroyed);
+	assert(notify_called); /* check if signal was emitted */
+	assert(wl_client_get_object(client, id) == NULL);
+
+	res = wl_resource_create(client, &wl_display_interface, 2, 0);
+	assert(res);
+	destroyed = 0;
+	notify_called = 0;
+	wl_resource_set_destructor(res, res_destroy_func);
+	wl_resource_set_user_data(res, &destroyed);
+	wl_resource_add_destroy_listener(res, &destroy_listener);
+	/* client should destroy the resource upon its destruction */
+	wl_client_destroy(client);
+	assert(destroyed);
+	assert(notify_called);
+
+	wl_display_destroy(display);
+	close(s[1]);
+}
+
+TEST(create_resource_with_same_id)
+{
+	struct wl_display *display;
+	struct wl_client *client;
+	struct wl_resource *res, *res2;
+	int s[2];
+	uint32_t id;
+
+	assert(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, s) == 0);
+	display = wl_display_create();
+	assert(display);
+	client = wl_client_create(display, s[0]);
+	assert(client);
+
+	res = wl_resource_create(client, &wl_display_interface, 2, 0);
+	assert(res);
+	id = wl_resource_get_id(res);
+	assert(wl_client_get_object(client, id) == res);
+
+	/* this one should replace the old one */
+	res2 = wl_resource_create(client, &wl_display_interface, 1, id);
+	assert(wl_client_get_object(client, id) == res2);
+
+	wl_resource_destroy(res2);
+	wl_resource_destroy(res);
+
+	wl_client_destroy(client);
+	wl_display_destroy(display);
+	close(s[1]);
+}

commit 1015a1947791a8b0a58c799ad966877d73f42336
Author: Marek Ch <mchqwerty@gmail.com>
Date:   Wed Sep 18 17:29:49 2013 +0200

    tests: add unit tests for wl_signal
    
    Test wl_signal initialization, adding and getting listeners and emitting

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 54157bc..3806cb6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -10,7 +10,8 @@ TESTS =						\
 	os-wrappers-test			\
 	sanity-test				\
 	socket-test				\
-	queue-test
+	queue-test				\
+	signal-test
 
 check_PROGRAMS =				\
 	$(TESTS)				\
@@ -32,6 +33,7 @@ map_test_SOURCES = map-test.c $(test_runner_src)
 sanity_test_SOURCES = sanity-test.c $(test_runner_src)
 socket_test_SOURCES = socket-test.c $(test_runner_src)
 queue_test_SOURCES = queue-test.c $(test_runner_src)
+signal_test_SOURCES = signal-test.c $(test_runner_src)
 
 fixed_benchmark_SOURCES = fixed-benchmark.c
 
diff --git a/tests/signal-test.c b/tests/signal-test.c
new file mode 100644
index 0000000..db83abc
--- /dev/null
+++ b/tests/signal-test.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright © 2013 Marek Chalupa
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+
+#include "wayland-server.h"
+#include "test-runner.h"
+
+static void
+signal_notify(struct wl_listener *listener, void *data)
+{
+	/* only increase counter*/
+	++(*((int *) data));
+}
+
+TEST(signal_init)
+{
+	struct wl_signal signal;
+
+	wl_signal_init(&signal);
+
+	/* Test if listeners' list is initialized */
+	assert(&signal.listener_list == signal.listener_list.next
+		&& "Maybe wl_signal implementation changed?");
+	assert(signal.listener_list.next == signal.listener_list.prev
+		&& "Maybe wl_signal implementation changed?");
+}
+
+TEST(signal_add_get)
+{
+	struct wl_signal signal;
+
+	/* we just need different values of notify */
+	struct wl_listener l1 = {.notify = (wl_notify_func_t) 0x1};
+	struct wl_listener l2 = {.notify = (wl_notify_func_t) 0x2};
+	struct wl_listener l3 = {.notify = (wl_notify_func_t) 0x3};
+	/* one real, why not */
+	struct wl_listener l4 = {.notify = signal_notify};
+
+	wl_signal_init(&signal);
+
+	wl_signal_add(&signal, &l1);
+	wl_signal_add(&signal, &l2);
+	wl_signal_add(&signal, &l3);
+	wl_signal_add(&signal, &l4);
+
+	assert(wl_signal_get(&signal, signal_notify) == &l4);
+	assert(wl_signal_get(&signal, (wl_notify_func_t) 0x3) == &l3);
+	assert(wl_signal_get(&signal, (wl_notify_func_t) 0x2) == &l2);
+	assert(wl_signal_get(&signal, (wl_notify_func_t) 0x1) == &l1);
+
+	/* get should not be destructive */
+	assert(wl_signal_get(&signal, signal_notify) == &l4);
+	assert(wl_signal_get(&signal, (wl_notify_func_t) 0x3) == &l3);
+	assert(wl_signal_get(&signal, (wl_notify_func_t) 0x2) == &l2);
+	assert(wl_signal_get(&signal, (wl_notify_func_t) 0x1) == &l1);
+}
+
+TEST(signal_emit_to_one_listener)
+{
+	int count = 0;
+	int counter;
+
+	struct wl_signal signal;
+	struct wl_listener l1 = {.notify = signal_notify};
+
+	wl_signal_init(&signal);
+	wl_signal_add(&signal, &l1);
+
+	for (counter = 0; counter < 100; counter++)
+		wl_signal_emit(&signal, &count);
+
+	assert(counter == count);
+}
+
+TEST(signal_emit_to_more_listeners)
+{
+	int count = 0;
+	int counter;
+
+	struct wl_signal signal;
+	struct wl_listener l1 = {.notify = signal_notify};
+	struct wl_listener l2 = {.notify = signal_notify};
+	struct wl_listener l3 = {.notify = signal_notify};
+
+	wl_signal_init(&signal);
+	wl_signal_add(&signal, &l1);
+	wl_signal_add(&signal, &l2);
+	wl_signal_add(&signal, &l3);
+
+	for (counter = 0; counter < 100; counter++)
+		wl_signal_emit(&signal, &count);
+
+	assert(3 * counter == count);
+}

commit 5eb480f04c1ee24a59f82f50bfc6b5fd451de0ab
Author: Marek Ch <mchqwerty@gmail.com>
Date:   Wed Sep 18 17:29:48 2013 +0200

    tests: extended message when leak in test is detected
    
    When memory or fd leak is detected, print how many blocks of memory were
    allocated and not freed, respectively how many files were opened/unclosed.

diff --git a/tests/test-runner.c b/tests/test-runner.c
index 9c6865a..8f3d5d3 100644
--- a/tests/test-runner.c
+++ b/tests/test-runner.c
@@ -111,13 +111,24 @@ static void
 run_test(const struct test *t)
 {
 	int cur_alloc = num_alloc;
-	int cur_fds;
+	int cur_fds, num_fds;
 
 	cur_fds = count_open_fds();
 	t->run();
 	if (leak_check_enabled) {
-		assert(cur_alloc == num_alloc && "memory leak detected in test.");
-		assert(cur_fds == count_open_fds() && "fd leak detected");
+		if (cur_alloc != num_alloc) {
+			fprintf(stderr, "Memory leak detected in test. "
+				"Allocated %d blocks, unfreed %d\n", num_alloc,
+				num_alloc - cur_alloc);
+			abort();
+		}
+		num_fds = count_open_fds();
+		if (cur_fds != num_fds) {
+			fprintf(stderr, "fd leak detected in test. "
+				"Opened %d files, unclosed %d\n", num_fds,
+				num_fds - cur_fds);
+			abort();
+		}
 	}
 	exit(EXIT_SUCCESS);
 }

commit 5b078470796ba292d6a2bac5dee571b77f0b7886
Author: Chang Liu <cl91tp@gmail.com>
Date:   Wed Sep 18 10:45:06 2013 +0000

    client: fix an inconsistency in documentation
    
    The errno is set to EAGAIN when there are undispatched events, according
    to L1066 of wayland-client.c.

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 04d988b..d043459 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -1087,7 +1087,7 @@ wl_display_prepare_read_queue(struct wl_display *display,
  * calls wl_display_read_events(), no other thread will read from the
  * file descriptor.  This only succeeds if the event queue is empty
  * though, and if there are undispatched events in the queue, -1 is
- * returned and errno set to EBUSY.
+ * returned and errno set to EAGAIN.
  *
  * If a thread successfully calls wl_display_prepare_read(), it must
  * either call wl_display_read_events() when it's ready or cancel the

commit 7a55448db2c25aa0c253dde59e4ab2695ea2749f
Author: Aaron Faanes <dafrito@gmail.com>
Date:   Tue Sep 17 16:44:24 2013 -0500

    doc: Slight tweaks to wl_listener
    
    Prefer \comment over // in code blocks for consistency's sake and keep
    variable definitions separated by a line from the rest of the body.

diff --git a/src/wayland-server.h b/src/wayland-server.h
index 997e6c7..c93987d 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -143,17 +143,18 @@ wl_client_post_no_memory(struct wl_client *client);
  * listener should be done through provided accessor methods. A listener can
  * only listen to one signal at a time.
  *
- * \code
+ * ~~~
  * struct wl_listener your_listener;
+ *
  * your_listener.notify = your_callback_method;
  *
- * // Direct access
+ * \comment{Direct access}
  * wl_signal_add(&some_object->destroy_signal, &your_listener);
  *
- * // Accessor access
+ * \comment{Accessor access}
  * wl_event_loop *loop = ...;
  * wl_event_loop_add_destroy_listener(loop, &your_listener);
- * \endcode
+ * ~~~
  *
  * If the listener is part of a larger struct, #wl_container_of can be used
  * to retrieve a pointer to it:
@@ -162,6 +163,7 @@ wl_client_post_no_memory(struct wl_client *client);
  * void your_listener(struct wl_listener *listener, void *data)
  * {
  * 	struct your_data *data = NULL;
+ *
  * 	your_data = wl_container_of(listener, data, your_member_name);
  * }
  * \endcode

commit 868be32191c32b9b85b71080a4f724da9bcb1e12
Author: Aaron Faanes <dafrito@gmail.com>
Date:   Tue Sep 17 16:42:43 2013 -0500

    utils: Document wl_container_of

diff --git a/src/wayland-util.h b/src/wayland-util.h
index aa74512..68d91e2 100644
--- a/src/wayland-util.h
+++ b/src/wayland-util.h
@@ -116,6 +116,41 @@ int wl_list_length(const struct wl_list *list);
 int wl_list_empty(const struct wl_list *list);
 void wl_list_insert_list(struct wl_list *list, struct wl_list *other);
 
+/**
+ * Retrieves a pointer to the containing struct of a given member item.
+ *
+ * This macro allows conversion from a pointer to a item to its containing
+ * struct. This is useful if you have a contained item like a wl_list,
+ * wl_listener, or wl_signal, provided via a callback or other means and would
+ * like to retrieve the struct that contains it.
+ *
+ * To demonstrate, the following example retrieves a pointer to
+ * `example_container` given only its `destroy_listener` member:
+ *
+ * ~~~
+ * struct example_container {
+ *     struct wl_listener destroy_listener;
+ *     \comment{other members...}
+ * };
+ *
+ * void example_container_destroy(struct wl_listener *listener, void *data)
+ * {
+ *     struct example_container *ctr = NULL;
+ *
+ *     ctr = wl_container_of(listener, ctr, destroy_listener);
+ *     \comment{destroy ctr...}
+ * }
+ * ~~~
+ *
+ * \param ptr A valid pointer to the contained item.
+ *
+ * \param sample A pointer to the type of content that the list item stores.
+ * Sample does not need be a valid pointer; a null pointer will suffice.
+ *
+ * \param member The named location of ptr within the sample type.
+ *
+ * \return The container for the specified pointer.
+ */
 #ifdef __GNUC__
 #define wl_container_of(ptr, sample, member)				\
 	(__typeof__(sample))((char *)(ptr)	-			\

commit 1823d9b952d3f4a01086f39021f63e2d00ddfaab
Author: Aaron Faanes <dafrito@gmail.com>
Date:   Tue Sep 17 16:40:49 2013 -0500

    doc: Create \comment alias for C-style comments
    
    Since /* */ do not nest, documentation is forced to either use C++ style
    // comments or some other foreign notation. This commit provides an alias
    that allows C-style comments to be introduced in code blocks that support
    aliases.
    
    It should be noted that this macro will not work within \code blocks, as
    Doxygen commands are ignored there. Instead, Doxygen's fenced code
    blocks (created via ~~~) must be used for proper output. To demonstrate:
    
    ~~~
    struct example_node {
            int id;
            \comment{Other members ...}
    };
    ~~~
    
    will roughly yield the following HTML (excluding syntax highlighting):
    
    <pre>
    struct example_node {
            int id;
            /* Other members ... */
    };
    </pre>

diff --git a/doc/doxygen/wayland.doxygen.in b/doc/doxygen/wayland.doxygen.in
index 7a2ac62..dd98594 100644
--- a/doc/doxygen/wayland.doxygen.in
+++ b/doc/doxygen/wayland.doxygen.in
@@ -193,7 +193,7 @@ TAB_SIZE               = 8
 # will result in a user-defined paragraph with heading "Side Effects:".
 # You can put \n's in the value part of an alias to insert newlines.
 
-ALIASES                =
+ALIASES                += comment{1}="/* \1 *<!-- -->/"
 
 # This tag can be used to specify a number of word-keyword mappings (TCL only).
 # A mapping has the form "name=value". For example adding

commit 5707091d5aa011913103688aca4a89bda40d6aa3
Author: Aaron Faanes <dafrito@gmail.com>
Date:   Sun Sep 15 13:37:09 2013 -0500

    doc: Include wayland-util.* for doxygen output
    
    This commit creates a shared file list that is included by both the
    client and the server for the XML Makefile targets, as classes within
    util are used by both the client and the server.

diff --git a/doc/doxygen/Makefile.am b/doc/doxygen/Makefile.am
index ec43519..0351c1e 100644
--- a/doc/doxygen/Makefile.am
+++ b/doc/doxygen/Makefile.am
@@ -2,11 +2,17 @@
 noinst_DATA = xml/client/index.xml xml/server/index.xml
 dist_noinst_DATA = wayland.doxygen.in
 
+scanned_src_files_shared = 				\
+	$(top_srcdir)/src/wayland-util.c	\
+	$(top_srcdir)/src/wayland-util.h
+
 scanned_src_files_client = 				\
+	$(scanned_src_files_shared)			\
 	$(top_srcdir)/src/wayland-client.c	\
 	$(top_srcdir)/src/wayland-client.h
 
 scanned_src_files_server = 				\
+	$(scanned_src_files_shared)			\
 	$(top_srcdir)/src/wayland-server.c	\
 	$(top_srcdir)/src/wayland-server.h
 

commit 6857ef16506fbe0535b1abea2f2e56e4fd0ad4ba
Author: Aaron Faanes <dafrito@gmail.com>
Date:   Sun Sep 15 13:37:08 2013 -0500

    wayland-server: Improve wording for wl_signal_get's doc
    
    The old description was a bit vague; this commit hopefully improves
    describing what is returned.

diff --git a/src/wayland-server.h b/src/wayland-server.h
index 2e616c1..997e6c7 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -221,7 +221,7 @@ wl_signal_add(struct wl_signal *signal, struct wl_listener *listener)
 	wl_list_insert(signal->listener_list.prev, &listener->link);
 }
 
-/** Gets the list item for the specified listener.
+/** Gets the listener struct for the specified callback.
  *
  * \param signal The signal that contains the specified listener
  * \param notify The listener that is the target of this search

commit 4744e9dbb576e4c8ba31b7ae07db767b655ff34d
Author: Aaron Faanes <dafrito@gmail.com>
Date:   Sun Sep 15 13:37:07 2013 -0500

    utils: Add doxygen for wayland-util.h
    
    This is needed for doxygen to generate output for macro definitions, such
    as wl_container_of, that are contained by this file. Classes like
    wl_list would be documented regardless.

diff --git a/src/wayland-util.h b/src/wayland-util.h
index de2e464..aa74512 100644
--- a/src/wayland-util.h
+++ b/src/wayland-util.h
@@ -20,6 +20,11 @@
  * OF THIS SOFTWARE.
  */
 
+/** \file wayland-util.h
+ *
+ * \brief Utility classes, functions, and macros.
+ */
+
 #ifndef WAYLAND_UTIL_H
 #define WAYLAND_UTIL_H
 

commit c4e11f0f92790aee87866c73aeed3c7149c0effb
Author: Aaron Faanes <dafrito@gmail.com>
Date:   Sun Sep 15 13:37:06 2013 -0500

    utils: Reference some useful methods in wl_signal's doxygen
    
    This commit adds a bit more detail on the lifecycle of a signal.

diff --git a/src/wayland-server.h b/src/wayland-server.h
index f345d2a..2e616c1 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -185,7 +185,12 @@ struct wl_listener {
  *
  * Signals are recognized points where significant events can be observed.
  * Compositors as well as the server can provide signals. Observers are
- * added through \ref wl_signal_add.
+ * wl_listener's that are added through #wl_signal_add. Signals are emitted
+ * using #wl_signal_emit, which will invoke all listeners until that
+ * listener is removed by #wl_list_remove (or whenever the signal is
+ * destroyed).
+ *
+ * \sa wl_listener for more information on using wl_signal
  */
 struct wl_signal {
 	struct wl_list listener_list;

commit dce9b81dbab51660e46a08c41d5b61b8591d8ac7
Author: Aaron Faanes <dafrito@gmail.com>
Date:   Sun Sep 15 13:09:18 2013 -0500

    wayland-server: Document wl_listener
    
    This patch takes Kristian's comments into account, adding a demonstration and
    giving a more thorough idea of how wl_listener is used.

diff --git a/src/wayland-server.h b/src/wayland-server.h
index 67f3bdd..f345d2a 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -129,6 +129,51 @@ wl_client_get_object(struct wl_client *client, uint32_t id);
 void
 wl_client_post_no_memory(struct wl_client *client);
 
+/** \class wl_listener
+ *
+ * \brief A single listener for Wayland signals
+ *
+ * wl_listener provides the means to listen for wl_signal notifications. Many
+ * Wayland objects use wl_listener for notification of significant events like
+ * object destruction.
+ *
+ * Clients should create wl_listener objects manually and can register them as
+ * listeners to signals using #wl_signal_add, assuming the signal is
+ * directly accessible. For opaque structs like wl_event_loop, adding a
+ * listener should be done through provided accessor methods. A listener can
+ * only listen to one signal at a time.
+ *
+ * \code
+ * struct wl_listener your_listener;
+ * your_listener.notify = your_callback_method;
+ *
+ * // Direct access
+ * wl_signal_add(&some_object->destroy_signal, &your_listener);
+ *
+ * // Accessor access
+ * wl_event_loop *loop = ...;
+ * wl_event_loop_add_destroy_listener(loop, &your_listener);
+ * \endcode
+ *
+ * If the listener is part of a larger struct, #wl_container_of can be used
+ * to retrieve a pointer to it:
+ *
+ * \code
+ * void your_listener(struct wl_listener *listener, void *data)
+ * {
+ * 	struct your_data *data = NULL;
+ * 	your_data = wl_container_of(listener, data, your_member_name);
+ * }
+ * \endcode
+ *
+ * If you need to remove a listener from a signal, use #wl_list_remove.
+ *
+ * \code
+ * wl_list_remove(&your_listener.link);
+ * \endcode
+ *
+ * \sa wl_signal
+ */
 struct wl_listener {
 	struct wl_list link;
 	wl_notify_func_t notify;

commit 29b3f856204a19e64bdc878d4c996fcbc5e0330c
Author: Chang Liu <cl91tp@gmail.com>
Date:   Sun Sep 8 11:12:33 2013 +0000

    gitignore: add ./compile
    
    ./compile is a GNU autotools helper script and should be ignored by git

diff --git a/.gitignore b/.gitignore
index 99b7089..f243100 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,7 @@ ctags
 /aclocal.m4
 /wayland-scanner.m4
 /autom4te.cache
+/compile
 /config.guess
 /config.h
 /config.h.in

commit ac1169ae2dc5d92274088a3c8826b1a47fcb892a
Author: Rob Bradford <rob@linux.intel.com>
Date:   Fri Sep 6 17:56:27 2013 +0100

    wayland-server: Add a wl_resource_for_each_safe macro
    
    A version of wl_resource_for_each that is safe for iteration when items
    in the list are removed.

diff --git a/src/wayland-server.h b/src/wayland-server.h
index 7404c3b..67f3bdd 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -350,6 +350,14 @@ wl_resource_get_destroy_listener(struct wl_resource *resource,
 	     wl_resource_get_link(resource) != (list);				\
 	     resource = wl_resource_from_link(wl_resource_get_link(resource)->next))
 
+#define wl_resource_for_each_safe(resource, tmp, list)					\
+	for (resource = 0, tmp = 0,							\
+	     resource = wl_resource_from_link((list)->next),	\
+	     tmp = wl_resource_from_link((list)->next->next);	\
+	     wl_resource_get_link(resource) != (list);				\
+	     resource = tmp,							\
+	     tmp = wl_resource_from_link(wl_resource_get_link(resource)->next))
+
 struct wl_shm_buffer;
 
 struct wl_shm_buffer *

commit 3e84fc2d701d0feb32bda447e8e12c59b0de4e36
Author: Aaron Faanes <dafrito@gmail.com>
Date:   Wed Aug 28 18:02:02 2013 -0500

    utils: tweak wl_list for better doxygen output

diff --git a/src/wayland-util.h b/src/wayland-util.h
index e5e4e25..de2e464 100644
--- a/src/wayland-util.h
+++ b/src/wayland-util.h
@@ -61,8 +61,9 @@ struct wl_interface {
 	const struct wl_message *events;
 };
 
-/**
- * wl_list - linked list
+/** \class wl_list
+ *
+ * \brief doubly-linked list
  *
  * The list head is of "struct wl_list" type, and must be initialized
  * using wl_list_init().  All entries in the list must be of the same

commit af08dc4a66cd7eca6d3544d2a53ea32d6ee5e3a9


Reply to: