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

wayland: Changes to 'upstream-experimental'



 .gitignore              |    1 
 configure.ac            |    2 -
 src/event-loop.c        |   21 ++++++++++++
 src/wayland-server.c    |   20 ++++++++++++
 src/wayland-server.h    |   11 ++++++
 tests/.gitignore        |    7 +++-
 tests/Makefile.am       |    2 +
 tests/display-test.c    |   79 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/event-loop-test.c |   64 ++++++++++++++++++++++++++++++++++++++
 9 files changed, 204 insertions(+), 3 deletions(-)

New commits:
commit 9ebb18418a1c3dccc19d3931766240b54227f131
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Thu Jan 24 20:33:31 2013 -0500

    configure.ac: Bump version to 1.0.4

diff --git a/configure.ac b/configure.ac
index 571ca97..c281125 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], [0])
-m4_define([wayland_micro_version], [3])
+m4_define([wayland_micro_version], [4])
 m4_define([wayland_version],
           [wayland_major_version.wayland_minor_version.wayland_micro_version])
 

commit 0929033a85a4ef37601d399293b47f2b907dcb0d
Author: David Herrmann <dh.herrmann@googlemail.com>
Date:   Wed Jan 23 14:20:41 2013 +0100

    gitignore: add test-suite files
    
    The *.log and *.trs files should be ignored by git as well as the GNU
    autotools ./test-driver helper script.
    
    Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>

diff --git a/.gitignore b/.gitignore
index 4f7a934..99b7089 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,5 +29,6 @@ ctags
 /ltmain.sh
 /missing
 /stamp-h1
+/test-driver
 Makefile
 Makefile.in
diff --git a/tests/.gitignore b/tests/.gitignore
index e97e294..ccd440a 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,6 +1,10 @@
+*.log
+*.trs
+
 array-test
 client-test
 connection-test
+display-test
 event-loop-test
 exec-fd-leak-checker
 fixed-benchmark
@@ -8,5 +12,6 @@ fixed-test
 list-test
 map-test
 os-wrappers-test
+queue-test
 sanity-test
-
+socket-test

commit 8a17f121cde0882a1de709ef3f54202bd8de6455
Author: David Herrmann <dh.herrmann@googlemail.com>
Date:   Wed Jan 23 14:11:19 2013 +0100

    event-loop: fix returning the destroy-signal listener
    
    We need to actually return the destroy-listener, otherwise the return
    value is undefined.
    
    Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>

diff --git a/src/event-loop.c b/src/event-loop.c
index 25e8f9c..e556cc7 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -447,6 +447,6 @@ WL_EXPORT struct wl_listener *
 wl_event_loop_get_destroy_listener(struct wl_event_loop *loop,
 				   wl_notify_func_t notify)
 {
-	wl_signal_get(&loop->destroy_signal, notify);
+	return wl_signal_get(&loop->destroy_signal, notify);
 }
 

commit 8cddb70d21a8b93b479fdbe63529e7a9837dfe73
Author: Jason Ekstrand <jason@jlekstrand.net>
Date:   Fri Jan 11 21:01:47 2013 -0600

    Add a destroy signal to the wl_event_loop object

diff --git a/src/event-loop.c b/src/event-loop.c
index 8db9c7c..25e8f9c 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -43,6 +43,8 @@ struct wl_event_loop {
 	struct wl_list check_list;
 	struct wl_list idle_list;
 	struct wl_list destroy_list;
+
+	struct wl_signal destroy_signal;
 };
 
 struct wl_event_source_interface {
@@ -357,12 +359,16 @@ wl_event_loop_create(void)
 	wl_list_init(&loop->idle_list);
 	wl_list_init(&loop->destroy_list);
 
+	wl_signal_init(&loop->destroy_signal);
+
 	return loop;
 }
 
 WL_EXPORT void
 wl_event_loop_destroy(struct wl_event_loop *loop)
 {
+	wl_signal_emit(&loop->destroy_signal, loop);
+
 	wl_event_loop_process_destroy_list(loop);
 	close(loop->epoll_fd);
 	free(loop);
@@ -429,3 +435,18 @@ wl_event_loop_get_fd(struct wl_event_loop *loop)
 {
 	return loop->epoll_fd;
 }
+
+WL_EXPORT void
+wl_event_loop_add_destroy_listener(struct wl_event_loop *loop,
+				   struct wl_listener *listener)
+{
+	wl_signal_add(&loop->destroy_signal, listener);
+}
+
+WL_EXPORT struct wl_listener *
+wl_event_loop_get_destroy_listener(struct wl_event_loop *loop,
+				   wl_notify_func_t notify)
+{
+	wl_signal_get(&loop->destroy_signal, notify);
+}
+
diff --git a/src/wayland-server.h b/src/wayland-server.h
index 576304f..c7369eb 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -84,6 +84,12 @@ struct wl_touch;
 struct wl_listener;
 typedef void (*wl_notify_func_t)(struct wl_listener *listener, void *data);
 
+void wl_event_loop_add_destroy_listener(struct wl_event_loop *loop,
+					struct wl_listener * listener);
+struct wl_listener *wl_event_loop_get_destroy_listener(
+					struct wl_event_loop *loop,
+					wl_notify_func_t notify);
+
 struct wl_display *wl_display_create(void);
 void wl_display_destroy(struct wl_display *display);
 struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c
index 2f3dcd4..c46d3b0 100644
--- a/tests/event-loop-test.c
+++ b/tests/event-loop-test.c
@@ -1,5 +1,6 @@
 /*
  * Copyright © 2012 Intel Corporation
+ * Copyright © 2012 Jason Ekstrand
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -25,6 +26,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include "wayland-server.h"
+#include "wayland-private.h"
 #include "test-runner.h"
 
 static int
@@ -190,3 +192,58 @@ TEST(event_loop_timer)
 	wl_event_source_remove(source);
 	wl_event_loop_destroy(loop);
 }
+
+struct event_loop_destroy_listener {
+	struct wl_listener listener;
+	int done;
+};
+
+static void
+event_loop_destroy_notify(struct wl_listener *l, void *data)
+{
+	struct event_loop_destroy_listener *listener =
+		container_of(l, struct event_loop_destroy_listener, listener);
+
+	listener->done = 1;
+}
+
+TEST(event_loop_destroy)
+{
+	struct wl_event_loop *loop;
+	struct wl_display * display;
+	struct event_loop_destroy_listener a, b;
+
+	loop = wl_event_loop_create();
+	assert(loop);
+
+	a.listener.notify = &event_loop_destroy_notify;
+	a.done = 0;
+	wl_event_loop_add_destroy_listener(loop, &a.listener);
+
+	assert(wl_event_loop_get_destroy_listener(loop,
+	       event_loop_destroy_notify) == &a.listener);
+
+	b.listener.notify = &event_loop_destroy_notify;
+	b.done = 0;
+	wl_event_loop_add_destroy_listener(loop, &b.listener);
+
+	wl_list_remove(&a.listener.link);
+	wl_event_loop_destroy(loop);
+
+	assert(!a.done);
+	assert(b.done);
+
+	/* Test to make sure it gets fired on display destruction */
+	display = wl_display_create();
+	assert(display);
+	loop = wl_display_get_event_loop(display);
+	assert(loop);
+
+	a.done = 0;
+	wl_event_loop_add_destroy_listener(loop, &a.listener);
+
+	wl_display_destroy(display);
+
+	assert(a.done);
+}
+

commit 945771c3d52dff751b48fde3c5c053013dc50747
Author: Quentin Glidic <sardemff7+git@sardemff7.net>
Date:   Sun Jan 6 15:46:00 2013 +0100

    test/event-loop: Check readable state on a pipe
    
    When redirecting stdout to a non-readable file makes the test fail as a
    false negative

diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c
index e630cde..2f3dcd4 100644
--- a/tests/event-loop-test.c
+++ b/tests/event-loop-test.c
@@ -43,14 +43,19 @@ TEST(event_loop_post_dispatch_check)
 	struct wl_event_loop *loop = wl_event_loop_create();
 	struct wl_event_source *source;
 	int dispatch_ran = 0;
+	int p[2];
 
-	source = wl_event_loop_add_fd(loop, 1, WL_EVENT_READABLE,
+	assert(pipe(p) == 0);
+
+	source = wl_event_loop_add_fd(loop, p[0], WL_EVENT_READABLE,
 				      fd_dispatch, &dispatch_ran);
 	wl_event_source_check(source);
 
 	wl_event_loop_dispatch(loop, 0);
 	assert(dispatch_ran);
 
+	assert(close(p[0]) == 0);
+	assert(close(p[1]) == 0);
 	wl_event_source_remove(source);
 	wl_event_loop_destroy(loop);
 }

commit 30ccd3366eda63154a7b39569d85378c82dbef20
Author: Jason Ekstrand <jason@jlekstrand.net>
Date:   Fri Jan 11 14:29:32 2013 -0600

    Added a destroy signal to the wl_display object.
    
    Added a destroy signal to the wl_display object.

diff --git a/src/wayland-server.c b/src/wayland-server.c
index f7f4c14..dae7177 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -90,6 +90,8 @@ struct wl_display {
 	struct wl_list global_list;
 	struct wl_list socket_list;
 	struct wl_list client_list;
+
+	struct wl_signal destroy_signal;
 };
 
 struct wl_global {
@@ -1096,6 +1098,8 @@ wl_display_create(void)
 	wl_list_init(&display->client_list);
 	wl_list_init(&display->registry_resource_list);
 
+	wl_signal_init(&display->destroy_signal);
+
 	display->id = 1;
 	display->serial = 0;
 
@@ -1115,6 +1119,8 @@ wl_display_destroy(struct wl_display *display)
 	struct wl_socket *s, *next;
 	struct wl_global *global, *gnext;
 
+	wl_signal_emit(&display->destroy_signal, display);
+
 	wl_list_for_each_safe(s, next, &display->socket_list, link) {
 		wl_event_source_remove(s->source);
 		unlink(s->addr.sun_path);
@@ -1381,6 +1387,20 @@ wl_display_add_socket(struct wl_display *display, const char *name)
 	return 0;
 }
 
+WL_EXPORT void
+wl_display_add_destroy_listener(struct wl_display *display,
+				struct wl_listener *listener)
+{
+	wl_signal_add(&display->destroy_signal, listener);
+}
+
+WL_EXPORT struct wl_listener *
+wl_display_get_destroy_listener(struct wl_display *display,
+				wl_notify_func_t notify)
+{
+	return wl_signal_get(&display->destroy_signal, notify);
+}
+
 WL_EXPORT struct wl_resource *
 wl_client_add_object(struct wl_client *client,
 		     const struct wl_interface *interface,
diff --git a/src/wayland-server.h b/src/wayland-server.h
index 3357105..576304f 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -106,6 +106,11 @@ void wl_display_remove_global(struct wl_display *display,
 uint32_t wl_display_get_serial(struct wl_display *display);
 uint32_t wl_display_next_serial(struct wl_display *display);
 
+void wl_display_add_destroy_listener(struct wl_display *display,
+				     struct wl_listener *listener);
+struct wl_listener *wl_display_get_destroy_listener(struct wl_display *display,
+						    wl_notify_func_t notify);
+
 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);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cf821c0..54157bc 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,7 @@
 TESTS =						\
 	array-test				\
 	client-test				\
+	display-test				\
 	connection-test				\
 	event-loop-test				\
 	fixed-test				\
@@ -22,6 +23,7 @@ test_runner_src = test-runner.c test-runner.h test-helpers.c
 
 array_test_SOURCES = array-test.c $(test_runner_src)
 client_test_SOURCES = client-test.c $(test_runner_src)
+display_test_SOURCES = display-test.c $(test_runner_src)
 connection_test_SOURCES = connection-test.c $(test_runner_src)
 event_loop_test_SOURCES = event-loop-test.c $(test_runner_src)
 fixed_test_SOURCES = fixed-test.c $(test_runner_src)
diff --git a/tests/display-test.c b/tests/display-test.c
new file mode 100644
index 0000000..95b939e
--- /dev/null
+++ b/tests/display-test.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ * Copyright © 2013 Jason Ekstrand
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "wayland-server.h"
+#include "wayland-private.h"
+#include "test-runner.h"
+
+struct display_destroy_listener {
+	struct wl_listener listener;
+	int done;
+};
+
+static void
+display_destroy_notify(struct wl_listener *l, void *data)
+{
+	struct display_destroy_listener *listener;
+
+	listener = container_of(l, struct display_destroy_listener, listener);
+	listener->done = 1;
+}
+
+TEST(display_destroy_listener)
+{
+	struct wl_display *display;
+	struct display_destroy_listener a, b;
+
+	display = wl_display_create();
+	assert(display);
+
+	a.listener.notify = &display_destroy_notify;
+	a.done = 0;
+	wl_display_add_destroy_listener(display, &a.listener);
+
+	assert(wl_display_get_destroy_listener(display, display_destroy_notify) ==
+	       &a.listener);
+
+	b.listener.notify = display_destroy_notify;
+	b.done = 0;
+	wl_display_add_destroy_listener(display, &b.listener);
+
+	wl_list_remove(&a.listener.link);
+
+	wl_display_destroy(display);
+
+	assert(!a.done);
+	assert(b.done);
+}
+


Reply to: